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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 63 - (show annotations)
Sat Feb 24 21:40:03 2007 UTC (8 years, 4 months ago) by nigel
File size: 1915 byte(s)
Error occurred while calculating annotation data.
Load pcre-4.0 into code/trunk.
1 .TH PCRE 3
2 .SH NAME
3 PCRE - Perl-compatible regular expressions
4 .SH PCRE SAMPLE PROGRAM
5 .rs
6 .sp
7 A simple, complete demonstration program, to get you started with using PCRE,
8 is supplied in the file \fIpcredemo.c\fR in the PCRE distribution.
9
10 The program compiles the regular expression that is its first argument, and
11 matches it against the subject string in its second argument. No PCRE options
12 are set, and default character tables are used. If matching succeeds, the
13 program outputs the portion of the subject that matched, together with the
14 contents of any captured substrings.
15
16 If the -g option is given on the command line, the program then goes on to
17 check for further matches of the same regular expression in the same subject
18 string. The logic is a little bit tricky because of the possibility of matching
19 an empty string. Comments in the code explain what is going on.
20
21 On a Unix system that has PCRE installed in \fI/usr/local\fR, you can compile
22 the demonstration program using a command like this:
23
24 gcc -o pcredemo pcredemo.c -I/usr/local/include \\
25 -L/usr/local/lib -lpcre
26
27 Then you can run simple tests like this:
28
29 ./pcredemo 'cat|dog' 'the cat sat on the mat'
30 ./pcredemo -g 'cat|dog' 'the dog sat on the cat'
31
32 Note that there is a much more comprehensive test program, called
33 \fBpcretest\fR, which supports many more facilities for testing regular
34 expressions and the PCRE library. The \fBpcredemo\fR program is provided as a
35 simple coding example.
36
37 On some operating systems (e.g. Solaris) you may get an error like this when
38 you try to run \fBpcredemo\fR:
39
40 ld.so.1: a.out: fatal: libpcre.so.0: open failed: No such file or directory
41
42 This is caused by the way shared library support works on those systems. You
43 need to add
44
45 -R/usr/local/lib
46
47 to the compile command to get round this problem.
48
49 .in 0
50 Last updated: 28 January 2003
51 .br
52 Copyright (c) 1997-2003 University of Cambridge.

  ViewVC Help
Powered by ViewVC 1.1.5