"Fossies" - the Fresh Open Source Software Archive
Member "pcre-8.43/doc/html/pcresample.html" (23 Feb 2019, 3784 Bytes) of package /linux/misc/pcre-8.43.tar.bz2:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) HTML source code syntax highlighting (style: standard
) with prefixed line numbers.
Alternatively you can here view
the uninterpreted source code file.
3 <title>pcresample specification</title>
5 <body bgcolor="#FFFFFF" text="#00005A" link="#0066FF" alink="#3399FF" vlink="#2222BB">
6 <h1>pcresample man page</h1>
8 Return to the <a href="index.html">PCRE index page</a>.
11 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.
16 PCRE SAMPLE PROGRAM
19 A simple, complete demonstration program, to get you started with using PCRE,
20 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 documentation. If you do not have a copy of the PCRE distribution, you can save
24 this listing to re-create <i>pcredemo.c</i>.
27 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
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.
41 If PCRE is installed in the standard include and library directories for your
42 operating system, you should be able to compile the demonstration program using
43 this command:
45 gcc -o pcredemo pcredemo.c -lpcre
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:
52 gcc -o pcredemo -I/usr/local/include pcredemo.c -L/usr/local/lib -lpcre
54 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.
61 Once you have compiled and linked the demonstration program, you can run simple
62 tests like this:
64 ./pcredemo 'cat|dog' 'the cat sat on the mat'
65 ./pcredemo -g 'cat|dog' 'the dog sat on the cat'
67 Note that there is a much more comprehensive test program, called
68 <a href="pcretest.html"><b>pcretest</b>,</a>
69 which supports many more facilities for testing regular expressions and both
70 PCRE libraries. The
71 <a href="pcredemo.html"><b>pcredemo</b></a>
72 program is provided as a simple coding example.
75 If you try to run
76 <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):
80 ld.so.1: a.out: fatal: libpcre.so.0: open failed: No such file or directory
82 This is caused by the way shared library support works on those systems. You
83 need to add
87 (for example) to the compile command to get round this problem.
93 Philip Hazel
95 University Computing Service
97 Cambridge CB2 3QH, England.
104 Last updated: 10 January 2012
106 Copyright © 1997-2012 University of Cambridge.
109 Return to the <a href="index.html">PCRE index page</a>.