ViewVC logotype

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

Parent Directory Parent Directory | Revision Log Revision Log

Revision 63 - (show annotations)
Sat Feb 24 21:40:03 2007 UTC (14 years, 1 month ago) by nigel
File MIME type: text/html
File size: 2438 byte(s)
Load pcre-4.0 into code/trunk.
1 <html>
2 <head>
3 <title>pcresample specification</title>
4 </head>
5 <body bgcolor="#FFFFFF" text="#00005A" link="#0066FF" alink="#3399FF" vlink="#2222BB">
6 This HTML document has been generated automatically from the original man page.
7 If there is any nonsense in it, please consult the man page, in case the
8 conversion went wrong.<br>
9 <ul>
10 <li><a name="TOC1" href="#SEC1">PCRE SAMPLE PROGRAM</a>
11 </ul>
12 <br><a name="SEC1" href="#TOC1">PCRE SAMPLE PROGRAM</a><br>
13 <P>
14 A simple, complete demonstration program, to get you started with using PCRE,
15 is supplied in the file <i>pcredemo.c</i> in the PCRE distribution.
16 </P>
17 <P>
18 The program compiles the regular expression that is its first argument, and
19 matches it against the subject string in its second argument. No PCRE options
20 are set, and default character tables are used. If matching succeeds, the
21 program outputs the portion of the subject that matched, together with the
22 contents of any captured substrings.
23 </P>
24 <P>
25 If the -g option is given on the command line, the program then goes on to
26 check for further matches of the same regular expression in the same subject
27 string. The logic is a little bit tricky because of the possibility of matching
28 an empty string. Comments in the code explain what is going on.
29 </P>
30 <P>
31 On a Unix system that has PCRE installed in <i>/usr/local</i>, you can compile
32 the demonstration program using a command like this:
33 </P>
34 <P>
35 <pre>
36 gcc -o pcredemo pcredemo.c -I/usr/local/include \
37 -L/usr/local/lib -lpcre
38 </PRE>
39 </P>
40 <P>
41 Then you can run simple tests like this:
42 </P>
43 <P>
44 <pre>
45 ./pcredemo 'cat|dog' 'the cat sat on the mat'
46 ./pcredemo -g 'cat|dog' 'the dog sat on the cat'
47 </PRE>
48 </P>
49 <P>
50 Note that there is a much more comprehensive test program, called
51 <b>pcretest</b>, which supports many more facilities for testing regular
52 expressions and the PCRE library. The <b>pcredemo</b> program is provided as a
53 simple coding example.
54 </P>
55 <P>
56 On some operating systems (e.g. Solaris) you may get an error like this when
57 you try to run <b>pcredemo</b>:
58 </P>
59 <P>
60 <pre>
61 ld.so.1: a.out: fatal: libpcre.so.0: open failed: No such file or directory
62 </PRE>
63 </P>
64 <P>
65 This is caused by the way shared library support works on those systems. You
66 need to add
67 </P>
68 <P>
69 <pre>
70 -R/usr/local/lib
71 </PRE>
72 </P>
73 <P>
74 to the compile command to get round this problem.
75 </P>
76 <P>
77 Last updated: 28 January 2003
78 <br>
79 Copyright &copy; 1997-2003 University of Cambridge.

  ViewVC Help
Powered by ViewVC 1.1.5