21 |
The distribution should contain the following files: |
The distribution should contain the following files: |
22 |
|
|
23 |
ChangeLog log of changes to the code |
ChangeLog log of changes to the code |
24 |
|
LICENCE conditions for the use of PCRE |
25 |
Makefile for building PCRE |
Makefile for building PCRE |
26 |
README this file |
README this file |
27 |
RunTest a shell script for running tests |
RunTest a shell script for running tests |
28 |
Tech.Notes notes on the encoding |
Tech.Notes notes on the encoding |
29 |
pcre.3 man page for the functions |
pcre.3 man page for the functions |
30 |
pcreposix.3 man page for the POSIX wrapper API |
pcreposix.3 man page for the POSIX wrapper API |
31 |
deftables.c auxiliary program for building chartables.c |
dftables.c auxiliary program for building chartables.c |
32 |
|
get.c ) |
33 |
maketables.c ) |
maketables.c ) |
34 |
study.c ) source of |
study.c ) source of |
35 |
pcre.c ) the functions |
pcre.c ) the functions |
71 |
main test input, which needs only Perl 5.004. In the long run, when 5.005 is |
main test input, which needs only Perl 5.004. In the long run, when 5.005 is |
72 |
widespread, these two test files may get amalgamated. |
widespread, these two test files may get amalgamated. |
73 |
|
|
74 |
The second set of tests check pcre_info(), pcre_study(), error detection and |
The second set of tests check pcre_info(), pcre_study(), pcre_copy_substring(), |
75 |
run-time flags that are specific to PCRE, as well as the POSIX wrapper API. |
pcre_get_substring(), pcre_get_substring_list(), error detection and run-time |
76 |
|
flags that are specific to PCRE, as well as the POSIX wrapper API. |
77 |
|
|
78 |
The fourth set of tests checks pcre_maketables(), the facility for building a |
The fourth set of tests checks pcre_maketables(), the facility for building a |
79 |
set of character tables for a specific locale and using them instead of the |
set of character tables for a specific locale and using them instead of the |
118 |
used. |
used. |
119 |
|
|
120 |
The source file called chartables.c contains the default set of tables. This is |
The source file called chartables.c contains the default set of tables. This is |
121 |
not supplied in the distribution, but is built by the program deftables |
not supplied in the distribution, but is built by the program dftables |
122 |
(compiled from deftables.c), which uses the ANSI C character handling functions |
(compiled from dftables.c), which uses the ANSI C character handling functions |
123 |
such as isalnum(), isalpha(), isupper(), islower(), etc. to build the table |
such as isalnum(), isalpha(), isupper(), islower(), etc. to build the table |
124 |
sources. This means that the default C locale set your system will control the |
sources. This means that the default C locale set your system will control the |
125 |
contents of the tables. You can change the default tables by editing |
contents of the tables. You can change the default tables by editing |
160 |
set starts with a regular expression, and continues with any number of data |
set starts with a regular expression, and continues with any number of data |
161 |
lines to be matched against the pattern. An empty line signals the end of the |
lines to be matched against the pattern. An empty line signals the end of the |
162 |
set. The regular expressions are given enclosed in any non-alphameric |
set. The regular expressions are given enclosed in any non-alphameric |
163 |
delimiters, for example |
delimiters other than backslash, for example |
164 |
|
|
165 |
/(a|bc)x+yz/ |
/(a|bc)x+yz/ |
166 |
|
|
167 |
and may be followed by i, m, s, or x to set the PCRE_CASELESS, PCRE_MULTILINE, |
White space before the initial delimiter is ignored. A regular expression may |
168 |
PCRE_DOTALL, or PCRE_EXTENDED options, respectively. These options have the |
be continued over several input lines, in which case the newline characters are |
169 |
same effect as they do in Perl. |
included within it. See the testinput files for many examples. It is possible |
170 |
|
to include the delimiter within the pattern by escaping it, for example |
171 |
|
|
172 |
|
/abc\/def/ |
173 |
|
|
174 |
|
If you do so, the escape and the delimiter form part of the pattern, but since |
175 |
|
delimiters are always non-alphameric, this does not affect its interpretation. |
176 |
|
If the terminating delimiter is immediately followed by a backslash, for |
177 |
|
example, |
178 |
|
|
179 |
|
/abc/\ |
180 |
|
|
181 |
|
then a backslash is added to the end of the pattern. This provides a way of |
182 |
|
testing the error condition that arises if a pattern finishes with a backslash, |
183 |
|
because |
184 |
|
|
185 |
|
/abc\/ |
186 |
|
|
187 |
|
is interpreted as the first line of a pattern that starts with "abc/", causing |
188 |
|
pcretest to read the next line as a continuation of the regular expression. |
189 |
|
|
190 |
|
The pattern may be followed by i, m, s, or x to set the PCRE_CASELESS, |
191 |
|
PCRE_MULTILINE, PCRE_DOTALL, or PCRE_EXTENDED options, respectively. These |
192 |
|
options have the same effect as they do in Perl. |
193 |
|
|
194 |
There are also some upper case options that do not match Perl options: /A, /E, |
There are also some upper case options that do not match Perl options: /A, /E, |
195 |
and /X set PCRE_ANCHORED, PCRE_DOLLAR_ENDONLY, and PCRE_EXTRA respectively. |
and /X set PCRE_ANCHORED, PCRE_DOLLAR_ENDONLY, and PCRE_EXTRA respectively. |
222 |
is present. The wrapper functions force PCRE_DOLLAR_ENDONLY always, and |
is present. The wrapper functions force PCRE_DOLLAR_ENDONLY always, and |
223 |
PCRE_DOTALL unless REG_NEWLINE is set. |
PCRE_DOTALL unless REG_NEWLINE is set. |
224 |
|
|
|
A regular expression can extend over several lines of input; the newlines are |
|
|
included in it. See the testinput files for many examples. |
|
|
|
|
225 |
Before each data line is passed to pcre_exec(), leading and trailing whitespace |
Before each data line is passed to pcre_exec(), leading and trailing whitespace |
226 |
is removed, and it is then scanned for \ escapes. The following are recognized: |
is removed, and it is then scanned for \ escapes. The following are recognized: |
227 |
|
|
238 |
|
|
239 |
\A pass the PCRE_ANCHORED option to pcre_exec() |
\A pass the PCRE_ANCHORED option to pcre_exec() |
240 |
\B pass the PCRE_NOTBOL option to pcre_exec() |
\B pass the PCRE_NOTBOL option to pcre_exec() |
241 |
|
\Cdd call pcre_copy_substring() for substring dd after a successful match |
242 |
|
(any decimal number less than 32) |
243 |
|
\Gdd call pcre_get_substring() for substring dd after a successful match |
244 |
|
(any decimal number less than 32) |
245 |
|
\L call pcre_get_substringlist() after a successful match |
246 |
\Odd set the size of the output vector passed to pcre_exec() to dd |
\Odd set the size of the output vector passed to pcre_exec() to dd |
247 |
(any number of decimal digits) |
(any number of decimal digits) |
248 |
\Z pass the PCRE_NOTEOL option to pcre_exec() |
\Z pass the PCRE_NOTEOL option to pcre_exec() |
255 |
\B, and \Z have any effect, causing REG_NOTBOL and REG_NOTEOL to be passed to |
\B, and \Z have any effect, causing REG_NOTBOL and REG_NOTEOL to be passed to |
256 |
regexec() respectively. |
regexec() respectively. |
257 |
|
|
258 |
When a match succeeds, pcretest outputs the list of identified substrings that |
When a match succeeds, pcretest outputs the list of captured substrings that |
259 |
pcre_exec() returns, starting with number 0 for the string that matched the |
pcre_exec() returns, starting with number 0 for the string that matched the |
260 |
whole pattern. Here is an example of an interactive pcretest run. |
whole pattern. Here is an example of an interactive pcretest run. |
261 |
|
|
270 |
data> xyz |
data> xyz |
271 |
No match |
No match |
272 |
|
|
273 |
|
If any of \C, \G, or \L are present in a data line that is successfully |
274 |
|
matched, the substrings extracted by the convenience functions are output with |
275 |
|
C, G, or L after the string number instead of a colon. This is in addition to |
276 |
|
the normal full list. The string length (that is, the return from the |
277 |
|
extraction function) is given in parentheses after each string for \C and \G. |
278 |
|
|
279 |
Note that while patterns can be continued over several lines (a plain ">" |
Note that while patterns can be continued over several lines (a plain ">" |
280 |
prompt is used for continuations), data lines may not. However newlines can be |
prompt is used for continuations), data lines may not. However newlines can be |
281 |
included in data by means of the \n escape. |
included in data by means of the \n escape. |
294 |
If the option -s is given to pcretest, it outputs the size of each compiled |
If the option -s is given to pcretest, it outputs the size of each compiled |
295 |
pattern after it has been compiled. |
pattern after it has been compiled. |
296 |
|
|
297 |
If the -t option is given, each compile, study, and match is run 10000 times |
If the -t option is given, each compile, study, and match is run 20000 times |
298 |
while being timed, and the resulting time per compile or match is output in |
while being timed, and the resulting time per compile or match is output in |
299 |
milliseconds. Do not set -t with -s, because you will then get the size output |
milliseconds. Do not set -t with -s, because you will then get the size output |
300 |
10000 times and the timing will be distorted. If you want to change the number |
20000 times and the timing will be distorted. If you want to change the number |
301 |
of repetitions used for timing, edit the definition of LOOPREPEAT at the top of |
of repetitions used for timing, edit the definition of LOOPREPEAT at the top of |
302 |
pcretest.c |
pcretest.c |
303 |
|
|
325 |
them correctly. |
them correctly. |
326 |
|
|
327 |
Philip Hazel <ph10@cam.ac.uk> |
Philip Hazel <ph10@cam.ac.uk> |
328 |
October 1998 |
February 1999 |