| 49 |
Behave as if each regex has the \fB/I\fP modifier; information about the |
Behave as if each regex has the \fB/I\fP modifier; information about the |
| 50 |
compiled pattern is given after compilation. |
compiled pattern is given after compilation. |
| 51 |
.TP 10 |
.TP 10 |
| 52 |
|
\fB-M\fP |
| 53 |
|
Behave as if each data line contains the \eM escape sequence; this causes |
| 54 |
|
PCRE to discover the minimum MATCH_LIMIT and MATCH_LIMIT_RECURSION settings by |
| 55 |
|
calling \fBpcre_exec()\fP repeatedly with different limits. |
| 56 |
|
.TP 10 |
| 57 |
\fB-m\fP |
\fB-m\fP |
| 58 |
Output the size of each compiled pattern after it has been compiled. This is |
Output the size of each compiled pattern after it has been compiled. This is |
| 59 |
equivalent to adding \fB/M\fP to each regular expression. For compatibility |
equivalent to adding \fB/M\fP to each regular expression. For compatibility |
| 102 |
stdout, and prompts for each line of input, using "re>" to prompt for regular |
stdout, and prompts for each line of input, using "re>" to prompt for regular |
| 103 |
expressions, and "data>" to prompt for data lines. |
expressions, and "data>" to prompt for data lines. |
| 104 |
.P |
.P |
| 105 |
|
When \fBpcretest\fP is built, a configuration option can specify that it should |
| 106 |
|
be linked with the \fBlibreadline\fP library. When this is done, if the input |
| 107 |
|
is from a terminal, it is read using the \fBreadline()\fP function. This |
| 108 |
|
provides line-editing and history facilities. The output from the \fB-help\fP |
| 109 |
|
option states whether or not \fBreadline()\fP will be used. |
| 110 |
|
.P |
| 111 |
The program handles any number of sets of input on a single input file. Each |
The program handles any number of sets of input on a single input file. Each |
| 112 |
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 |
| 113 |
lines to be matched against the pattern. |
lines to be matched against the pattern. |
| 168 |
The following table shows additional modifiers for setting PCRE options that do |
The following table shows additional modifiers for setting PCRE options that do |
| 169 |
not correspond to anything in Perl: |
not correspond to anything in Perl: |
| 170 |
.sp |
.sp |
| 171 |
\fB/A\fP PCRE_ANCHORED |
\fB/A\fP PCRE_ANCHORED |
| 172 |
\fB/C\fP PCRE_AUTO_CALLOUT |
\fB/C\fP PCRE_AUTO_CALLOUT |
| 173 |
\fB/E\fP PCRE_DOLLAR_ENDONLY |
\fB/E\fP PCRE_DOLLAR_ENDONLY |
| 174 |
\fB/f\fP PCRE_FIRSTLINE |
\fB/f\fP PCRE_FIRSTLINE |
| 175 |
\fB/J\fP PCRE_DUPNAMES |
\fB/J\fP PCRE_DUPNAMES |
| 176 |
\fB/N\fP PCRE_NO_AUTO_CAPTURE |
\fB/N\fP PCRE_NO_AUTO_CAPTURE |
| 177 |
\fB/U\fP PCRE_UNGREEDY |
\fB/U\fP PCRE_UNGREEDY |
| 178 |
\fB/X\fP PCRE_EXTRA |
\fB/X\fP PCRE_EXTRA |
| 179 |
\fB/<cr>\fP PCRE_NEWLINE_CR |
\fB/<JS>\fP PCRE_JAVASCRIPT_COMPAT |
| 180 |
\fB/<lf>\fP PCRE_NEWLINE_LF |
\fB/<cr>\fP PCRE_NEWLINE_CR |
| 181 |
\fB/<crlf>\fP PCRE_NEWLINE_CRLF |
\fB/<lf>\fP PCRE_NEWLINE_LF |
| 182 |
\fB/<anycrlf>\fP PCRE_NEWLINE_ANYCRLF |
\fB/<crlf>\fP PCRE_NEWLINE_CRLF |
| 183 |
\fB/<any>\fP PCRE_NEWLINE_ANY |
\fB/<anycrlf>\fP PCRE_NEWLINE_ANYCRLF |
| 184 |
|
\fB/<any>\fP PCRE_NEWLINE_ANY |
| 185 |
|
\fB/<bsr_anycrlf>\fP PCRE_BSR_ANYCRLF |
| 186 |
|
\fB/<bsr_unicode>\fP PCRE_BSR_UNICODE |
| 187 |
.sp |
.sp |
| 188 |
Those specifying line ending sequences are literal strings as shown, but the |
Those specifying line ending sequences are literal strings as shown, but the |
| 189 |
letters can be in either case. This example sets multiline matching with CRLF |
letters can be in either case. This example sets multiline matching with CRLF |
| 211 |
begins with a lookbehind assertion (including \eb or \eB). |
begins with a lookbehind assertion (including \eb or \eB). |
| 212 |
.P |
.P |
| 213 |
If any call to \fBpcre_exec()\fP in a \fB/g\fP or \fB/G\fP sequence matches an |
If any call to \fBpcre_exec()\fP in a \fB/g\fP or \fB/G\fP sequence matches an |
| 214 |
empty string, the next call is done with the PCRE_NOTEMPTY and PCRE_ANCHORED |
empty string, the next call is done with the PCRE_NOTEMPTY_ATSTART and |
| 215 |
flags set in order to search for another, non-empty, match at the same point. |
PCRE_ANCHORED flags set in order to search for another, non-empty, match at the |
| 216 |
If this second match fails, the start offset is advanced by one, and the normal |
same point. If this second match fails, the start offset is advanced by one |
| 217 |
match is retried. This imitates the way Perl handles such cases when using the |
character, and the normal match is retried. This imitates the way Perl handles |
| 218 |
\fB/g\fP modifier or the \fBsplit()\fP function. |
such cases when using the \fB/g\fP modifier or the \fBsplit()\fP function. |
| 219 |
. |
. |
| 220 |
. |
. |
| 221 |
.SS "Other modifiers" |
.SS "Other modifiers" |
| 356 |
MATCH_LIMIT_RECURSION settings |
MATCH_LIMIT_RECURSION settings |
| 357 |
.\" JOIN |
.\" JOIN |
| 358 |
\eN pass the PCRE_NOTEMPTY option to \fBpcre_exec()\fP |
\eN pass the PCRE_NOTEMPTY option to \fBpcre_exec()\fP |
| 359 |
or \fBpcre_dfa_exec()\fP |
or \fBpcre_dfa_exec()\fP; if used twice, pass the |
| 360 |
|
PCRE_NOTEMPTY_ATSTART option |
| 361 |
.\" JOIN |
.\" JOIN |
| 362 |
\eOdd set the size of the output vector passed to |
\eOdd set the size of the output vector passed to |
| 363 |
\fBpcre_exec()\fP to dd (any number of digits) |
\fBpcre_exec()\fP to dd (any number of digits) |
| 364 |
.\" JOIN |
.\" JOIN |
| 365 |
\eP pass the PCRE_PARTIAL option to \fBpcre_exec()\fP |
\eP pass the PCRE_PARTIAL_SOFT option to \fBpcre_exec()\fP |
| 366 |
or \fBpcre_dfa_exec()\fP |
or \fBpcre_dfa_exec()\fP; if used twice, pass the |
| 367 |
|
PCRE_PARTIAL_HARD option |
| 368 |
.\" JOIN |
.\" JOIN |
| 369 |
\eQdd set the PCRE_MATCH_LIMIT_RECURSION limit to dd |
\eQdd set the PCRE_MATCH_LIMIT_RECURSION limit to dd |
| 370 |
(any number of digits) |
(any number of digits) |
| 462 |
.P |
.P |
| 463 |
When a match succeeds, pcretest outputs the list of captured substrings that |
When a match succeeds, pcretest outputs the list of captured substrings that |
| 464 |
\fBpcre_exec()\fP returns, starting with number 0 for the string that matched |
\fBpcre_exec()\fP returns, starting with number 0 for the string that matched |
| 465 |
the whole pattern. Otherwise, it outputs "No match" or "Partial match" |
the whole pattern. Otherwise, it outputs "No match" when the return is |
| 466 |
when \fBpcre_exec()\fP returns PCRE_ERROR_NOMATCH or PCRE_ERROR_PARTIAL, |
PCRE_ERROR_NOMATCH, and "Partial match:" followed by the partially matching |
| 467 |
respectively, and otherwise the PCRE negative error number. Here is an example |
substring when \fBpcre_exec()\fP returns PCRE_ERROR_PARTIAL. For any other |
| 468 |
of an interactive \fBpcretest\fP run. |
returns, it outputs the PCRE negative error number. Here is an example of an |
| 469 |
|
interactive \fBpcretest\fP run. |
| 470 |
.sp |
.sp |
| 471 |
$ pcretest |
$ pcretest |
| 472 |
PCRE version 7.0 30-Nov-2006 |
PCRE version 7.0 30-Nov-2006 |
| 478 |
data> xyz |
data> xyz |
| 479 |
No match |
No match |
| 480 |
.sp |
.sp |
| 481 |
|
Note that unset capturing substrings that are not followed by one that is set |
| 482 |
|
are not returned by \fBpcre_exec()\fP, and are not shown by \fBpcretest\fP. In |
| 483 |
|
the following example, there are two capturing substrings, but when the first |
| 484 |
|
data line is matched, the second, unset substring is not shown. An "internal" |
| 485 |
|
unset substring is shown as "<unset>", as for the second data line. |
| 486 |
|
.sp |
| 487 |
|
re> /(a)|(b)/ |
| 488 |
|
data> a |
| 489 |
|
0: a |
| 490 |
|
1: a |
| 491 |
|
data> b |
| 492 |
|
0: b |
| 493 |
|
1: <unset> |
| 494 |
|
2: b |
| 495 |
|
.sp |
| 496 |
If the strings contain any non-printing characters, they are output as \e0x |
If the strings contain any non-printing characters, they are output as \e0x |
| 497 |
escapes, or as \ex{...} escapes if the \fB/8\fP modifier was present on the |
escapes, or as \ex{...} escapes if the \fB/8\fP modifier was present on the |
| 498 |
pattern. See below for the definition of non-printing characters. If the |
pattern. See below for the definition of non-printing characters. If the |
| 547 |
2: tan |
2: tan |
| 548 |
.sp |
.sp |
| 549 |
(Using the normal matching function on this data finds only "tang".) The |
(Using the normal matching function on this data finds only "tang".) The |
| 550 |
longest matching string is always given first (and numbered zero). |
longest matching string is always given first (and numbered zero). After a |
| 551 |
|
PCRE_ERROR_PARTIAL return, the output is "Partial match:", followed by the |
| 552 |
|
partially matching substring. |
| 553 |
.P |
.P |
| 554 |
If \fB/g\fP is present on the pattern, the search for further matches resumes |
If \fB/g\fP is present on the pattern, the search for further matches resumes |
| 555 |
at the end of the longest match. For example: |
at the end of the longest match. For example: |
| 728 |
.rs |
.rs |
| 729 |
.sp |
.sp |
| 730 |
.nf |
.nf |
| 731 |
Last updated: 21 August 2007 |
Last updated: 11 September 2009 |
| 732 |
Copyright (c) 1997-2007 University of Cambridge. |
Copyright (c) 1997-2009 University of Cambridge. |
| 733 |
.fi |
.fi |