| 77 |
compiled pattern is given after compilation. |
compiled pattern is given after compilation. |
| 78 |
</P> |
</P> |
| 79 |
<P> |
<P> |
| 80 |
|
<b>-M</b> |
| 81 |
|
Behave as if each data line contains the \M escape sequence; this causes |
| 82 |
|
PCRE to discover the minimum MATCH_LIMIT and MATCH_LIMIT_RECURSION settings by |
| 83 |
|
calling <b>pcre_exec()</b> repeatedly with different limits. |
| 84 |
|
</P> |
| 85 |
|
<P> |
| 86 |
<b>-m</b> |
<b>-m</b> |
| 87 |
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 |
| 88 |
equivalent to adding <b>/M</b> to each regular expression. For compatibility |
equivalent to adding <b>/M</b> to each regular expression. For compatibility |
| 136 |
expressions, and "data>" to prompt for data lines. |
expressions, and "data>" to prompt for data lines. |
| 137 |
</P> |
</P> |
| 138 |
<P> |
<P> |
| 139 |
|
When <b>pcretest</b> is built, a configuration option can specify that it should |
| 140 |
|
be linked with the <b>libreadline</b> library. When this is done, if the input |
| 141 |
|
is from a terminal, it is read using the <b>readline()</b> function. This |
| 142 |
|
provides line-editing and history facilities. The output from the <b>-help</b> |
| 143 |
|
option states whether or not <b>readline()</b> will be used. |
| 144 |
|
</P> |
| 145 |
|
<P> |
| 146 |
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 |
| 147 |
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 |
| 148 |
lines to be matched against the pattern. |
lines to be matched against the pattern. |
| 204 |
The following table shows additional modifiers for setting PCRE options that do |
The following table shows additional modifiers for setting PCRE options that do |
| 205 |
not correspond to anything in Perl: |
not correspond to anything in Perl: |
| 206 |
<pre> |
<pre> |
| 207 |
<b>/A</b> PCRE_ANCHORED |
<b>/A</b> PCRE_ANCHORED |
| 208 |
<b>/C</b> PCRE_AUTO_CALLOUT |
<b>/C</b> PCRE_AUTO_CALLOUT |
| 209 |
<b>/E</b> PCRE_DOLLAR_ENDONLY |
<b>/E</b> PCRE_DOLLAR_ENDONLY |
| 210 |
<b>/f</b> PCRE_FIRSTLINE |
<b>/f</b> PCRE_FIRSTLINE |
| 211 |
<b>/J</b> PCRE_DUPNAMES |
<b>/J</b> PCRE_DUPNAMES |
| 212 |
<b>/N</b> PCRE_NO_AUTO_CAPTURE |
<b>/N</b> PCRE_NO_AUTO_CAPTURE |
| 213 |
<b>/U</b> PCRE_UNGREEDY |
<b>/U</b> PCRE_UNGREEDY |
| 214 |
<b>/X</b> PCRE_EXTRA |
<b>/X</b> PCRE_EXTRA |
| 215 |
<b>/<cr></b> PCRE_NEWLINE_CR |
<b>/<JS></b> PCRE_JAVASCRIPT_COMPAT |
| 216 |
<b>/<lf></b> PCRE_NEWLINE_LF |
<b>/<cr></b> PCRE_NEWLINE_CR |
| 217 |
<b>/<crlf></b> PCRE_NEWLINE_CRLF |
<b>/<lf></b> PCRE_NEWLINE_LF |
| 218 |
<b>/<anycrlf></b> PCRE_NEWLINE_ANYCRLF |
<b>/<crlf></b> PCRE_NEWLINE_CRLF |
| 219 |
<b>/<any></b> PCRE_NEWLINE_ANY |
<b>/<anycrlf></b> PCRE_NEWLINE_ANYCRLF |
| 220 |
</pre> |
<b>/<any></b> PCRE_NEWLINE_ANY |
| 221 |
Those specifying line ending sequencess are literal strings as shown. This |
<b>/<bsr_anycrlf></b> PCRE_BSR_ANYCRLF |
| 222 |
example sets multiline matching with CRLF as the line ending sequence: |
<b>/<bsr_unicode></b> PCRE_BSR_UNICODE |
| 223 |
|
</pre> |
| 224 |
|
Those specifying line ending sequences are literal strings as shown, but the |
| 225 |
|
letters can be in either case. This example sets multiline matching with CRLF |
| 226 |
|
as the line ending sequence: |
| 227 |
<pre> |
<pre> |
| 228 |
/^abc/m<crlf> |
/^abc/m<crlf> |
| 229 |
</pre> |
</pre> |
| 246 |
</P> |
</P> |
| 247 |
<P> |
<P> |
| 248 |
If any call to <b>pcre_exec()</b> in a <b>/g</b> or <b>/G</b> sequence matches an |
If any call to <b>pcre_exec()</b> in a <b>/g</b> or <b>/G</b> sequence matches an |
| 249 |
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 |
| 250 |
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 |
| 251 |
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 |
| 252 |
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 |
| 253 |
<b>/g</b> modifier or the <b>split()</b> function. |
such cases when using the <b>/g</b> modifier or the <b>split()</b> function. |
| 254 |
</P> |
</P> |
| 255 |
<br><b> |
<br><b> |
| 256 |
Other modifiers |
Other modifiers |
| 370 |
ated by next non-alphanumeric character) |
ated by next non-alphanumeric character) |
| 371 |
\L call pcre_get_substringlist() after a successful match |
\L call pcre_get_substringlist() after a successful match |
| 372 |
\M discover the minimum MATCH_LIMIT and MATCH_LIMIT_RECURSION settings |
\M discover the minimum MATCH_LIMIT and MATCH_LIMIT_RECURSION settings |
| 373 |
\N pass the PCRE_NOTEMPTY option to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b> |
\N pass the PCRE_NOTEMPTY option to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>; if used twice, pass the |
| 374 |
|
PCRE_NOTEMPTY_ATSTART option |
| 375 |
\Odd set the size of the output vector passed to <b>pcre_exec()</b> to dd (any number of digits) |
\Odd set the size of the output vector passed to <b>pcre_exec()</b> to dd (any number of digits) |
| 376 |
\P pass the PCRE_PARTIAL option to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b> |
\P pass the PCRE_PARTIAL_SOFT option to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>; if used twice, pass the |
| 377 |
|
PCRE_PARTIAL_HARD option |
| 378 |
\Qdd set the PCRE_MATCH_LIMIT_RECURSION limit to dd (any number of digits) |
\Qdd set the PCRE_MATCH_LIMIT_RECURSION limit to dd (any number of digits) |
| 379 |
\R pass the PCRE_DFA_RESTART option to <b>pcre_dfa_exec()</b> |
\R pass the PCRE_DFA_RESTART option to <b>pcre_dfa_exec()</b> |
| 380 |
\S output details of memory get/free calls during matching |
\S output details of memory get/free calls during matching |
| 381 |
|
\Y pass the PCRE_NO_START_OPTIMIZE option to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b> |
| 382 |
\Z pass the PCRE_NOTEOL option to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b> |
\Z pass the PCRE_NOTEOL option to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b> |
| 383 |
\? pass the PCRE_NO_UTF8_CHECK option to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b> |
\? pass the PCRE_NO_UTF8_CHECK option to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b> |
| 384 |
\>dd start the match at offset dd (any number of digits); |
\>dd start the match at offset dd (any number of digits); |
| 456 |
<P> |
<P> |
| 457 |
When a match succeeds, pcretest outputs the list of captured substrings that |
When a match succeeds, pcretest outputs the list of captured substrings that |
| 458 |
<b>pcre_exec()</b> returns, starting with number 0 for the string that matched |
<b>pcre_exec()</b> returns, starting with number 0 for the string that matched |
| 459 |
the whole pattern. Otherwise, it outputs "No match" or "Partial match" |
the whole pattern. Otherwise, it outputs "No match" when the return is |
| 460 |
when <b>pcre_exec()</b> returns PCRE_ERROR_NOMATCH or PCRE_ERROR_PARTIAL, |
PCRE_ERROR_NOMATCH, and "Partial match:" followed by the partially matching |
| 461 |
respectively, and otherwise the PCRE negative error number. Here is an example |
substring when <b>pcre_exec()</b> returns PCRE_ERROR_PARTIAL. For any other |
| 462 |
of an interactive <b>pcretest</b> run. |
returns, it outputs the PCRE negative error number. Here is an example of an |
| 463 |
|
interactive <b>pcretest</b> run. |
| 464 |
<pre> |
<pre> |
| 465 |
$ pcretest |
$ pcretest |
| 466 |
PCRE version 7.0 30-Nov-2006 |
PCRE version 7.0 30-Nov-2006 |
| 472 |
data> xyz |
data> xyz |
| 473 |
No match |
No match |
| 474 |
</pre> |
</pre> |
| 475 |
|
Note that unset capturing substrings that are not followed by one that is set |
| 476 |
|
are not returned by <b>pcre_exec()</b>, and are not shown by <b>pcretest</b>. In |
| 477 |
|
the following example, there are two capturing substrings, but when the first |
| 478 |
|
data line is matched, the second, unset substring is not shown. An "internal" |
| 479 |
|
unset substring is shown as "<unset>", as for the second data line. |
| 480 |
|
<pre> |
| 481 |
|
re> /(a)|(b)/ |
| 482 |
|
data> a |
| 483 |
|
0: a |
| 484 |
|
1: a |
| 485 |
|
data> b |
| 486 |
|
0: b |
| 487 |
|
1: <unset> |
| 488 |
|
2: b |
| 489 |
|
</pre> |
| 490 |
If the strings contain any non-printing characters, they are output as \0x |
If the strings contain any non-printing characters, they are output as \0x |
| 491 |
escapes, or as \x{...} escapes if the <b>/8</b> modifier was present on the |
escapes, or as \x{...} escapes if the <b>/8</b> modifier was present on the |
| 492 |
pattern. See below for the definition of non-printing characters. If the |
pattern. See below for the definition of non-printing characters. If the |
| 540 |
2: tan |
2: tan |
| 541 |
</pre> |
</pre> |
| 542 |
(Using the normal matching function on this data finds only "tang".) The |
(Using the normal matching function on this data finds only "tang".) The |
| 543 |
longest matching string is always given first (and numbered zero). |
longest matching string is always given first (and numbered zero). After a |
| 544 |
|
PCRE_ERROR_PARTIAL return, the output is "Partial match:", followed by the |
| 545 |
|
partially matching substring. |
| 546 |
</P> |
</P> |
| 547 |
<P> |
<P> |
| 548 |
If <b>/g</b> is present on the pattern, the search for further matches resumes |
If <b>/g</b> is present on the pattern, the search for further matches resumes |
| 709 |
</P> |
</P> |
| 710 |
<br><a name="SEC15" href="#TOC1">REVISION</a><br> |
<br><a name="SEC15" href="#TOC1">REVISION</a><br> |
| 711 |
<P> |
<P> |
| 712 |
Last updated: 09 August 2007 |
Last updated: 26 September 2009 |
| 713 |
<br> |
<br> |
| 714 |
Copyright © 1997-2007 University of Cambridge. |
Copyright © 1997-2009 University of Cambridge. |
| 715 |
<br> |
<br> |
| 716 |
<p> |
<p> |
| 717 |
Return to the <a href="index.html">PCRE index page</a>. |
Return to the <a href="index.html">PCRE index page</a>. |