/[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 429 - (show annotations)
Tue Sep 1 16:10:16 2009 UTC (10 years ago) by ph10
File MIME type: text/html
File size: 3351 byte(s)
Add pcredemo man page, containing a listing of pcredemo.c.
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 program compiles the regular expression that is its first argument, and
28 matches it against the subject string in its second argument. No PCRE options
29 are set, and default character tables are used. If matching succeeds, the
30 program outputs the portion of the subject that matched, together with the
31 contents of any captured substrings.
32 </P>
33 <P>
34 If the -g option is given on the command line, the program then goes on to
35 check for further matches of the same regular expression in the same subject
36 string. The logic is a little bit tricky because of the possibility of matching
37 an empty string. Comments in the code explain what is going on.
38 </P>
39 <P>
40 If PCRE is installed in the standard include and library directories for your
41 system, you should be able to compile the demonstration program using this
42 command:
43 <pre>
44 gcc -o pcredemo pcredemo.c -lpcre
45 </pre>
46 If PCRE is installed elsewhere, you may need to add additional options to the
47 command line. For example, on a Unix-like system that has PCRE installed in
48 <i>/usr/local</i>, you can compile the demonstration program using a command
49 like this:
50 <pre>
51 gcc -o pcredemo -I/usr/local/include pcredemo.c -L/usr/local/lib -lpcre
52 </pre>
53 Once you have compiled the demonstration program, you can run simple tests like
54 this:
55 <pre>
56 ./pcredemo 'cat|dog' 'the cat sat on the mat'
57 ./pcredemo -g 'cat|dog' 'the dog sat on the cat'
58 </pre>
59 Note that there is a much more comprehensive test program, called
60 <a href="pcretest.html"><b>pcretest</b>,</a>
61 which supports many more facilities for testing regular expressions and the
62 PCRE library. The
63 <a href="pcredemo.html"><b>pcredemo</b></a>
64 program is provided as a simple coding example.
65 </P>
66 <P>
67 When you try to run
68 <a href="pcredemo.html"><b>pcredemo</b></a>
69 when PCRE is not installed in the standard library directory, you may get an
70 error like this on some operating systems (e.g. Solaris):
71 <pre>
72 ld.so.1: a.out: fatal: libpcre.so.0: open failed: No such file or directory
73 </pre>
74 This is caused by the way shared library support works on those systems. You
75 need to add
76 <pre>
77 -R/usr/local/lib
78 </pre>
79 (for example) to the compile command to get round this problem.
80 </P>
81 <br><b>
82 AUTHOR
83 </b><br>
84 <P>
85 Philip Hazel
86 <br>
87 University Computing Service
88 <br>
89 Cambridge CB2 3QH, England.
90 <br>
91 </P>
92 <br><b>
93 REVISION
94 </b><br>
95 <P>
96 Last updated: 01 September 2009
97 <br>
98 Copyright &copy; 1997-2009 University of Cambridge.
99 <br>
100 <p>
101 Return to the <a href="index.html">PCRE index page</a>.
102 </p>

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.5