ViewVC logotype

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

Parent Directory Parent Directory | Revision Log Revision Log

Revision 181 - (show annotations)
Wed Jun 13 14:55:18 2007 UTC (14 years, 4 months ago) by ph10
File size: 2642 byte(s)
Error occurred while calculating annotation data.
Documentation update preparatory to release.
3 PCRE - Perl-compatible regular expressions
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\fP in the PCRE distribution.
9 .P
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 .P
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 .P
21 The demonstration program is automatically built if you use "./configure;make"
22 to build PCRE. Otherwise, if PCRE is installed in the standard include and
23 library directories for your system, you should be able to compile the
24 demonstration program using this command:
25 .sp
26 gcc -o pcredemo pcredemo.c -lpcre
27 .sp
28 If PCRE is installed elsewhere, you may need to add additional options to the
29 command line. For example, on a Unix-like system that has PCRE installed in
30 \fI/usr/local\fP, you can compile the demonstration program using a command
31 like this:
32 .sp
33 .\" JOINSH
34 gcc -o pcredemo -I/usr/local/include pcredemo.c \e
35 -L/usr/local/lib -lpcre
36 .sp
37 Once you have compiled the demonstration program, you can run simple tests like
38 this:
39 .sp
40 ./pcredemo 'cat|dog' 'the cat sat on the mat'
41 ./pcredemo -g 'cat|dog' 'the dog sat on the cat'
42 .sp
43 Note that there is a much more comprehensive test program, called
44 .\" HREF
45 \fBpcretest\fP,
46 .\"
47 which supports many more facilities for testing regular expressions and the
48 PCRE library. The \fBpcredemo\fP program is provided as a simple coding
49 example.
50 .P
51 On some operating systems (e.g. Solaris), when PCRE is not installed in the
52 standard library directory, you may get an error like this when you try to run
53 \fBpcredemo\fP:
54 .sp
55 ld.so.1: a.out: fatal: libpcre.so.0: open failed: No such file or directory
56 .sp
57 This is caused by the way shared library support works on those systems. You
58 need to add
59 .sp
60 -R/usr/local/lib
61 .sp
62 (for example) to the compile command to get round this problem.
63 .
64 .
66 .rs
67 .sp
68 .nf
69 Philip Hazel
70 University Computing Service
71 Cambridge CB2 3QH, England.
72 .fi
73 .
74 .
76 .rs
77 .sp
78 .nf
79 Last updated: 13 June 2007
80 Copyright (c) 1997-2007 University of Cambridge.
81 .fi


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

  ViewVC Help
Powered by ViewVC 1.1.5