/[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 869 - (hide annotations) (download) (as text)
Sat Jan 14 11:16:23 2012 UTC (16 months ago) by ph10
File MIME type: text/html
File size: 3784 byte(s)
Bring HTML docs up to date.

1 nigel 63 <html>
2     <head>
3     <title>pcresample specification</title>
4     </head>
5     <body bgcolor="#FFFFFF" text="#00005A" link="#0066FF" alink="#3399FF" vlink="#2222BB">
6 nigel 75 <h1>pcresample man page</h1>
7     <p>
8     Return to the <a href="index.html">PCRE index page</a>.
9     </p>
10 ph10 111 <p>
11 nigel 75 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 ph10 111 <br>
15 nigel 75 <br><b>
16     PCRE SAMPLE PROGRAM
17     </b><br>
18 nigel 63 <P>
19     A simple, complete demonstration program, to get you started with using PCRE,
20 ph10 429 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 ph10 461 documentation. If you do not have a copy of the PCRE distribution, you can save
24 ph10 429 this listing to re-create <i>pcredemo.c</i>.
25 nigel 63 </P>
26     <P>
27 ph10 869 The demonstration program, which uses the original PCRE 8-bit library, compiles
28     the regular expression that is its first argument, and matches it against the
29     subject string in its second argument. No PCRE options are set, and default
30     character tables are used. If matching succeeds, the program outputs the
31     portion of the subject that matched, together with the contents of any captured
32     substrings.
33 nigel 63 </P>
34     <P>
35     If the -g option is given on the command line, the program then goes on to
36     check for further matches of the same regular expression in the same subject
37     string. The logic is a little bit tricky because of the possibility of matching
38     an empty string. Comments in the code explain what is going on.
39     </P>
40     <P>
41 ph10 313 If PCRE is installed in the standard include and library directories for your
42 ph10 461 operating system, you should be able to compile the demonstration program using
43     this command:
44 nigel 63 <pre>
45 nigel 75 gcc -o pcredemo pcredemo.c -lpcre
46     </pre>
47     If PCRE is installed elsewhere, you may need to add additional options to the
48     command line. For example, on a Unix-like system that has PCRE installed in
49     <i>/usr/local</i>, you can compile the demonstration program using a command
50     like this:
51 nigel 63 <pre>
52 nigel 75 gcc -o pcredemo -I/usr/local/include pcredemo.c -L/usr/local/lib -lpcre
53     </pre>
54 ph10 535 In a Windows environment, if you want to statically link the program against a
55     non-dll <b>pcre.a</b> file, you must uncomment the line that defines PCRE_STATIC
56     before including <b>pcre.h</b>, because otherwise the <b>pcre_malloc()</b> and
57     <b>pcre_free()</b> exported functions will be declared
58     <b>__declspec(dllimport)</b>, with unwanted results.
59     </P>
60     <P>
61     Once you have compiled and linked the demonstration program, you can run simple
62     tests like this:
63 nigel 75 <pre>
64 nigel 63 ./pcredemo 'cat|dog' 'the cat sat on the mat'
65     ./pcredemo -g 'cat|dog' 'the dog sat on the cat'
66 nigel 75 </pre>
67 nigel 63 Note that there is a much more comprehensive test program, called
68 nigel 75 <a href="pcretest.html"><b>pcretest</b>,</a>
69 ph10 869 which supports many more facilities for testing regular expressions and both
70     PCRE libraries. The
71 ph10 429 <a href="pcredemo.html"><b>pcredemo</b></a>
72     program is provided as a simple coding example.
73 nigel 63 </P>
74     <P>
75 ph10 579 If you try to run
76 ph10 429 <a href="pcredemo.html"><b>pcredemo</b></a>
77     when PCRE is not installed in the standard library directory, you may get an
78     error like this on some operating systems (e.g. Solaris):
79 nigel 63 <pre>
80     ld.so.1: a.out: fatal: libpcre.so.0: open failed: No such file or directory
81 nigel 75 </pre>
82 nigel 63 This is caused by the way shared library support works on those systems. You
83     need to add
84     <pre>
85     -R/usr/local/lib
86 nigel 75 </pre>
87     (for example) to the compile command to get round this problem.
88 nigel 63 </P>
89 ph10 99 <br><b>
90     AUTHOR
91     </b><br>
92 nigel 63 <P>
93 ph10 99 Philip Hazel
94 nigel 63 <br>
95 ph10 99 University Computing Service
96     <br>
97     Cambridge CB2 3QH, England.
98     <br>
99     </P>
100     <br><b>
101     REVISION
102     </b><br>
103     <P>
104 ph10 869 Last updated: 10 January 2012
105 ph10 99 <br>
106 ph10 869 Copyright &copy; 1997-2012 University of Cambridge.
107 ph10 99 <br>
108 nigel 75 <p>
109     Return to the <a href="index.html">PCRE index page</a>.
110     </p>

Properties

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

webmaster@exim.org
ViewVC Help
Powered by ViewVC 1.1.12