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