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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 63 by nigel, Sat Feb 24 21:40:03 2007 UTC revision 75 by nigel, Sat Feb 24 21:40:37 2007 UTC
# Line 1  Line 1 
1  .TH PCRE 3  .TH PCRE 3
2  .SH NAME  .SH NAME
3  PCRE - Perl-compatible regular expressions  PCRE - Perl-compatible regular expressions
4  .SH PCRE SAMPLE PROGRAM  .SH "PCRE SAMPLE PROGRAM"
5  .rs  .rs
6  .sp  .sp
7  A simple, complete demonstration program, to get you started with using PCRE,  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.  is supplied in the file \fIpcredemo.c\fP in the PCRE distribution.
9    .P
10  The program compiles the regular expression that is its first argument, and  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  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  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  program outputs the portion of the subject that matched, together with the
14  contents of any captured substrings.  contents of any captured substrings.
15    .P
16  If the -g option is given on the command line, the program then goes on to  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  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  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.  an empty string. Comments in the code explain what is going on.
20    .P
21  On a Unix system that has PCRE installed in \fI/usr/local\fR, you can compile  If PCRE is installed in the standard include and library directories for your
22  the demonstration program using a command like this:  system, you should be able to compile the demonstration program using this
23    command:
24    gcc -o pcredemo pcredemo.c -I/usr/local/include \\  .sp
25      gcc -o pcredemo pcredemo.c -lpcre
26    .sp
27    If PCRE is installed elsewhere, you may need to add additional options to the
28    command line. For example, on a Unix-like system that has PCRE installed in
29    \fI/usr/local\fP, you can compile the demonstration program using a command
30    like this:
31    .sp
32    .\" JOINSH
33      gcc -o pcredemo -I/usr/local/include pcredemo.c \e
34        -L/usr/local/lib -lpcre        -L/usr/local/lib -lpcre
35    .sp
36  Then you can run simple tests like this:  Once you have compiled the demonstration program, you can run simple tests like
37    this:
38    .sp
39    ./pcredemo 'cat|dog' 'the cat sat on the mat'    ./pcredemo 'cat|dog' 'the cat sat on the mat'
40    ./pcredemo -g 'cat|dog' 'the dog sat on the cat'    ./pcredemo -g 'cat|dog' 'the dog sat on the cat'
41    .sp
42  Note that there is a much more comprehensive test program, called  Note that there is a much more comprehensive test program, called
43  \fBpcretest\fR, which supports many more facilities for testing regular  .\" HREF
44  expressions and the PCRE library. The \fBpcredemo\fR program is provided as a  \fBpcretest\fP,
45  simple coding example.  .\"
46    which supports many more facilities for testing regular expressions and the
47  On some operating systems (e.g. Solaris) you may get an error like this when  PCRE library. The \fBpcredemo\fP program is provided as a simple coding
48  you try to run \fBpcredemo\fR:  example.
49    .P
50    On some operating systems (e.g. Solaris), when PCRE is not installed in the
51    standard library directory, you may get an error like this when you try to run
52    \fBpcredemo\fP:
53    .sp
54    ld.so.1: a.out: fatal: libpcre.so.0: open failed: No such file or directory    ld.so.1: a.out: fatal: libpcre.so.0: open failed: No such file or directory
55    .sp
56  This is caused by the way shared library support works on those systems. You  This is caused by the way shared library support works on those systems. You
57  need to add  need to add
58    .sp
59    -R/usr/local/lib    -R/usr/local/lib
60    .sp
61  to the compile command to get round this problem.  (for example) to the compile command to get round this problem.
62    .P
63  .in 0  .in 0
64  Last updated: 28 January 2003  Last updated: 09 September 2004
65  .br  .br
66  Copyright (c) 1997-2003 University of Cambridge.  Copyright (c) 1997-2004 University of Cambridge.

Legend:
Removed from v.63  
changed lines
  Added in v.75

webmaster@exim.org
ViewVC Help
Powered by ViewVC 1.1.12