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 program compiles the regular expression that is its first argument, and 28matches it against the subject string in its second argument. No PCRE options 29are set, and default character tables are used. If matching succeeds, the 30program outputs the portion of the subject that matched, together with the 31contents of any captured substrings. 32</P> 33<P> 34If the -g option is given on the command line, the program then goes on to 35check for further matches of the same regular expression in the same subject 36string. The logic is a little bit tricky because of the possibility of matching 37an empty string. Comments in the code explain what is going on. 38</P> 39<P> 40If PCRE is installed in the standard include and library directories for your 41operating system, you should be able to compile the demonstration program using 42this command: 43<pre> 44 gcc -o pcredemo pcredemo.c -lpcre 45</pre> 46If PCRE is installed elsewhere, you may need to add additional options to the 47command line. For example, on a Unix-like system that has PCRE installed in 48<i>/usr/local</i>, you can compile the demonstration program using a command 49like this: 50<pre> 51 gcc -o pcredemo -I/usr/local/include pcredemo.c -L/usr/local/lib -lpcre 52</pre> 53Once you have compiled the demonstration program, you can run simple tests like 54this: 55<pre> 56 /pcredemo 'cat|dog' 'the cat sat on the mat' 57 /pcredemo -g 'cat|dog' 'the dog sat on the cat' 58</pre> 59Note that there is a much more comprehensive test program, called 60<a href="pcretest.html"><b>pcretest</b>,</a> 61which supports many more facilities for testing regular expressions and the 62PCRE library. The 63<a href="pcredemo.html"><b>pcredemo</b></a> 64program is provided as a simple coding example. 65</P> 66<P> 67When you try to run 68<a href="pcredemo.html"><b>pcredemo</b></a> 69when PCRE is not installed in the standard library directory, you may get an 70error like this on some operating systems (e.g. Solaris): 71<pre> 72 ld.so.1: a.out: fatal: libpcre.so.0: open failed: No such file or directory 73</pre> 74This is caused by the way shared library support works on those systems. You 75need to add 76<pre> 77 -R/usr/local/lib 78</pre> 79(for example) to the compile command to get round this problem. 80</P> 81<br><b> 82AUTHOR 83</b><br> 84<P> 85Philip Hazel 86<br> 87University Computing Service 88<br> 89Cambridge CB2 3QH, England. 90<br> 91</P> 92<br><b> 93REVISION 94</b><br> 95<P> 96Last updated: 30 September 2009 97<br> 98Copyright © 1997-2009 University of Cambridge. 99<br> 100<p> 101Return to the <a href="index.html">PCRE index page</a>. 102</p> 103