/[pcre]/code/trunk/doc/html/pcresample.html
ViewVC logotype

Contents of /code/trunk/doc/html/pcresample.html

Parent Directory Parent Directory | Revision Log Revision Log


Revision 869 - (show annotations)
Sat Jan 14 11:16:23 2012 UTC (7 years, 7 months ago) by ph10
File MIME type: text/html
File size: 3784 byte(s)
Bring HTML docs up to date.
1 <html>
2 <head>
3 <title>pcresample specification</title>
4 </head>
5 <body bgcolor="#FFFFFF" text="#00005A" link="#0066FF" alink="#3399FF" vlink="#2222BB">
6 <h1>pcresample man page</h1>
7 <p>
8 Return to the <a href="index.html">PCRE index page</a>.
9 </p>
10 <p>
11 This page is part of the PCRE HTML documentation. It was generated automatically
12 from the original man page. If there is any nonsense in it, please consult the
13 man page, in case the conversion went wrong.
14 <br>
15 <br><b>
16 PCRE SAMPLE PROGRAM
17 </b><br>
18 <P>
19 A simple, complete demonstration program, to get you started with using PCRE,
20 is supplied in the file <i>pcredemo.c</i> in the PCRE distribution. A listing of
21 this program is given in the
22 <a href="pcredemo.html"><b>pcredemo</b></a>
23 documentation. If you do not have a copy of the PCRE distribution, you can save
24 this listing to re-create <i>pcredemo.c</i>.
25 </P>
26 <P>
27 The demonstration program, which uses the original PCRE 8-bit library, compiles
28 the regular expression that is its first argument, and matches it against the
29 subject string in its second argument. No PCRE options are set, and default
30 character tables are used. If matching succeeds, the program outputs the
31 portion of the subject that matched, together with the contents of any captured
32 substrings.
33 </P>
34 <P>
35 If the -g option is given on the command line, the program then goes on to
36 check for further matches of the same regular expression in the same subject
37 string. The logic is a little bit tricky because of the possibility of matching
38 an empty string. Comments in the code explain what is going on.
39 </P>
40 <P>
41 If PCRE is installed in the standard include and library directories for your
42 operating system, you should be able to compile the demonstration program using
43 this command:
44 <pre>
45 gcc -o pcredemo pcredemo.c -lpcre
46 </pre>
47 If PCRE is installed elsewhere, you may need to add additional options to the
48 command line. For example, on a Unix-like system that has PCRE installed in
49 <i>/usr/local</i>, you can compile the demonstration program using a command
50 like this:
51 <pre>
52 gcc -o pcredemo -I/usr/local/include pcredemo.c -L/usr/local/lib -lpcre
53 </pre>
54 In a Windows environment, if you want to statically link the program against a
55 non-dll <b>pcre.a</b> file, you must uncomment the line that defines PCRE_STATIC
56 before including <b>pcre.h</b>, because otherwise the <b>pcre_malloc()</b> and
57 <b>pcre_free()</b> exported functions will be declared
58 <b>__declspec(dllimport)</b>, with unwanted results.
59 </P>
60 <P>
61 Once you have compiled and linked the demonstration program, you can run simple
62 tests like this:
63 <pre>
64 ./pcredemo 'cat|dog' 'the cat sat on the mat'
65 ./pcredemo -g 'cat|dog' 'the dog sat on the cat'
66 </pre>
67 Note that there is a much more comprehensive test program, called
68 <a href="pcretest.html"><b>pcretest</b>,</a>
69 which supports many more facilities for testing regular expressions and both
70 PCRE libraries. The
71 <a href="pcredemo.html"><b>pcredemo</b></a>
72 program is provided as a simple coding example.
73 </P>
74 <P>
75 If you try to run
76 <a href="pcredemo.html"><b>pcredemo</b></a>
77 when PCRE is not installed in the standard library directory, you may get an
78 error like this on some operating systems (e.g. Solaris):
79 <pre>
80 ld.so.1: a.out: fatal: libpcre.so.0: open failed: No such file or directory
81 </pre>
82 This is caused by the way shared library support works on those systems. You
83 need to add
84 <pre>
85 -R/usr/local/lib
86 </pre>
87 (for example) to the compile command to get round this problem.
88 </P>
89 <br><b>
90 AUTHOR
91 </b><br>
92 <P>
93 Philip Hazel
94 <br>
95 University Computing Service
96 <br>
97 Cambridge CB2 3QH, England.
98 <br>
99 </P>
100 <br><b>
101 REVISION
102 </b><br>
103 <P>
104 Last updated: 10 January 2012
105 <br>
106 Copyright &copy; 1997-2012 University of Cambridge.
107 <br>
108 <p>
109 Return to the <a href="index.html">PCRE index page</a>.
110 </p>

Properties

Name Value
svn:eol-style native
svn:keywords "Author Date Id Revision Url"

  ViewVC Help
Powered by ViewVC 1.1.5