/[pcre]/code/trunk/doc/html/pcretest.html
ViewVC logotype

Diff of /code/trunk/doc/html/pcretest.html

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 512 by ph10, Tue Mar 30 11:11:52 2010 UTC revision 836 by ph10, Wed Dec 28 17:16:11 2011 UTC
# Line 14  man page, in case the conversion went wr Line 14  man page, in case the conversion went wr
14  <br>  <br>
15  <ul>  <ul>
16  <li><a name="TOC1" href="#SEC1">SYNOPSIS</a>  <li><a name="TOC1" href="#SEC1">SYNOPSIS</a>
17  <li><a name="TOC2" href="#SEC2">OPTIONS</a>  <li><a name="TOC2" href="#SEC2">COMMAND LINE OPTIONS</a>
18  <li><a name="TOC3" href="#SEC3">DESCRIPTION</a>  <li><a name="TOC3" href="#SEC3">DESCRIPTION</a>
19  <li><a name="TOC4" href="#SEC4">PATTERN MODIFIERS</a>  <li><a name="TOC4" href="#SEC4">PATTERN MODIFIERS</a>
20  <li><a name="TOC5" href="#SEC5">DATA LINES</a>  <li><a name="TOC5" href="#SEC5">DATA LINES</a>
# Line 31  man page, in case the conversion went wr Line 31  man page, in case the conversion went wr
31  </ul>  </ul>
32  <br><a name="SEC1" href="#TOC1">SYNOPSIS</a><br>  <br><a name="SEC1" href="#TOC1">SYNOPSIS</a><br>
33  <P>  <P>
34  <b>pcretest [options] [source] [destination]</b>  <b>pcretest [options] [input file [output file]]</b>
35  <br>  <br>
36  <br>  <br>
37  <b>pcretest</b> was written as a test program for the PCRE regular expression  <b>pcretest</b> was written as a test program for the PCRE regular expression
# Line 42  details of the regular expressions thems Line 42  details of the regular expressions thems
42  documentation. For details of the PCRE library function calls and their  documentation. For details of the PCRE library function calls and their
43  options, see the  options, see the
44  <a href="pcreapi.html"><b>pcreapi</b></a>  <a href="pcreapi.html"><b>pcreapi</b></a>
45  documentation.  documentation. The input for <b>pcretest</b> is a sequence of regular expression
46    patterns and strings to be matched, as described below. The output shows the
47    result of each match. Options on the command line and the patterns control PCRE
48    options and exactly what is output.
49  </P>  </P>
50  <br><a name="SEC2" href="#TOC1">OPTIONS</a><br>  <br><a name="SEC2" href="#TOC1">COMMAND LINE OPTIONS</a><br>
51  <P>  <P>
52  <b>-b</b>  <b>-b</b>
53  Behave as if each regex has the <b>/B</b> (show bytecode) modifier; the internal  Behave as if each pattern has the <b>/B</b> (show byte code) modifier; the
54  form is output after compilation.  internal form is output after compilation.
55  </P>  </P>
56  <P>  <P>
57  <b>-C</b>  <b>-C</b>
# Line 57  about the optional features that are inc Line 60  about the optional features that are inc
60  </P>  </P>
61  <P>  <P>
62  <b>-d</b>  <b>-d</b>
63  Behave as if each regex has the <b>/D</b> (debug) modifier; the internal  Behave as if each pattern has the <b>/D</b> (debug) modifier; the internal
64  form and information about the compiled pattern is output after compilation;  form and information about the compiled pattern is output after compilation;
65  <b>-d</b> is equivalent to <b>-b -i</b>.  <b>-d</b> is equivalent to <b>-b -i</b>.
66  </P>  </P>
# Line 73  Output a brief summary these options and Line 76  Output a brief summary these options and
76  </P>  </P>
77  <P>  <P>
78  <b>-i</b>  <b>-i</b>
79  Behave as if each regex has the <b>/I</b> modifier; information about the  Behave as if each pattern has the <b>/I</b> modifier; information about the
80  compiled pattern is given after compilation.  compiled pattern is given after compilation.
81  </P>  </P>
82  <P>  <P>
# Line 85  calling <b>pcre_exec()</b> repeatedly wi Line 88  calling <b>pcre_exec()</b> repeatedly wi
88  <P>  <P>
89  <b>-m</b>  <b>-m</b>
90  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
91  equivalent to adding <b>/M</b> to each regular expression. For compatibility  equivalent to adding <b>/M</b> to each regular expression.
 with earlier versions of pcretest, <b>-s</b> is a synonym for <b>-m</b>.  
92  </P>  </P>
93  <P>  <P>
94  <b>-o</b> <i>osize</i>  <b>-o</b> <i>osize</i>
# Line 99  below). Line 101  below).
101  </P>  </P>
102  <P>  <P>
103  <b>-p</b>  <b>-p</b>
104  Behave as if each regex has the <b>/P</b> modifier; the POSIX wrapper API is  Behave as if each pattern has the <b>/P</b> modifier; the POSIX wrapper API is
105  used to call PCRE. None of the other options has any effect when <b>-p</b> is  used to call PCRE. None of the other options has any effect when <b>-p</b> is
106  set.  set.
107  </P>  </P>
# Line 109  Do not output the version number of <b>p Line 111  Do not output the version number of <b>p
111  </P>  </P>
112  <P>  <P>
113  <b>-S</b> <i>size</i>  <b>-S</b> <i>size</i>
114  On Unix-like systems, set the size of the runtime stack to <i>size</i>  On Unix-like systems, set the size of the run-time stack to <i>size</i>
115  megabytes.  megabytes.
116  </P>  </P>
117  <P>  <P>
118    <b>-s</b> or <b>-s+</b>
119    Behave as if each pattern has the <b>/S</b> modifier; in other words, force each
120    pattern to be studied. If <b>-s+</b> is used, the PCRE_STUDY_JIT_COMPILE flag is
121    passed to <b>pcre_study()</b>, causing just-in-time optimization to be set up if
122    it is available. If the <b>/I</b> or <b>/D</b> option is present on a pattern
123    (requesting output about the compiled pattern), information about the result of
124    studying is not included when studying is caused only by <b>-s</b> and neither
125    <b>-i</b> nor <b>-d</b> is present on the command line. This behaviour means that
126    the output from tests that are run with and without <b>-s</b> should be
127    identical, except when options that output information about the actual running
128    of a match are set. The <b>-M</b>, <b>-t</b>, and <b>-tm</b> options, which give
129    information about resources used, are likely to produce different output with
130    and without <b>-s</b>. Output may also differ if the <b>/C</b> option is present
131    on an individual pattern. This uses callouts to trace the the matching process,
132    and this may be different between studied and non-studied patterns. If the
133    pattern contains (*MARK) items there may also be differences, for the same
134    reason. The <b>-s</b> command line option can be overridden for specific
135    patterns that should never be studied (see the <b>/S</b> pattern modifier
136    below).
137    </P>
138    <P>
139  <b>-t</b>  <b>-t</b>
140  Run each compile, study, and match many times with a timer, and output  Run each compile, study, and match many times with a timer, and output
141  resulting time per compile or match (in milliseconds). Do not set <b>-m</b> with  resulting time per compile or match (in milliseconds). Do not set <b>-m</b> with
# Line 189  pcretest to read the next line as a cont Line 212  pcretest to read the next line as a cont
212  A pattern may be followed by any number of modifiers, which are mostly single  A pattern may be followed by any number of modifiers, which are mostly single
213  characters. Following Perl usage, these are referred to below as, for example,  characters. Following Perl usage, these are referred to below as, for example,
214  "the <b>/i</b> modifier", even though the delimiter of the pattern need not  "the <b>/i</b> modifier", even though the delimiter of the pattern need not
215  always be a slash, and no slash is used when writing modifiers. Whitespace may  always be a slash, and no slash is used when writing modifiers. White space may
216  appear between the final pattern delimiter and the first modifier, and between  appear between the final pattern delimiter and the first modifier, and between
217  the modifiers themselves.  the modifiers themselves.
218  </P>  </P>
# Line 201  effect as they do in Perl. For example: Line 224  effect as they do in Perl. For example:
224  <pre>  <pre>
225    /caseless/i    /caseless/i
226  </pre>  </pre>
227  The following table shows additional modifiers for setting PCRE options that do  The following table shows additional modifiers for setting PCRE compile-time
228  not correspond to anything in Perl:  options that do not correspond to anything in Perl:
229  <pre>  <pre>
230      <b>/8</b>              PCRE_UTF8
231      <b>/?</b>              PCRE_NO_UTF8_CHECK
232    <b>/A</b>              PCRE_ANCHORED    <b>/A</b>              PCRE_ANCHORED
233    <b>/C</b>              PCRE_AUTO_CALLOUT    <b>/C</b>              PCRE_AUTO_CALLOUT
234    <b>/E</b>              PCRE_DOLLAR_ENDONLY    <b>/E</b>              PCRE_DOLLAR_ENDONLY
# Line 211  not correspond to anything in Perl: Line 236  not correspond to anything in Perl:
236    <b>/J</b>              PCRE_DUPNAMES    <b>/J</b>              PCRE_DUPNAMES
237    <b>/N</b>              PCRE_NO_AUTO_CAPTURE    <b>/N</b>              PCRE_NO_AUTO_CAPTURE
238    <b>/U</b>              PCRE_UNGREEDY    <b>/U</b>              PCRE_UNGREEDY
239      <b>/W</b>              PCRE_UCP
240    <b>/X</b>              PCRE_EXTRA    <b>/X</b>              PCRE_EXTRA
241      <b>/Y</b>              PCRE_NO_START_OPTIMIZE
242    <b>/&#60;JS&#62;</b>           PCRE_JAVASCRIPT_COMPAT    <b>/&#60;JS&#62;</b>           PCRE_JAVASCRIPT_COMPAT
243    <b>/&#60;cr&#62;</b>           PCRE_NEWLINE_CR    <b>/&#60;cr&#62;</b>           PCRE_NEWLINE_CR
244    <b>/&#60;lf&#62;</b>           PCRE_NEWLINE_LF    <b>/&#60;lf&#62;</b>           PCRE_NEWLINE_LF
# Line 221  not correspond to anything in Perl: Line 248  not correspond to anything in Perl:
248    <b>/&#60;bsr_anycrlf&#62;</b>  PCRE_BSR_ANYCRLF    <b>/&#60;bsr_anycrlf&#62;</b>  PCRE_BSR_ANYCRLF
249    <b>/&#60;bsr_unicode&#62;</b>  PCRE_BSR_UNICODE    <b>/&#60;bsr_unicode&#62;</b>  PCRE_BSR_UNICODE
250  </pre>  </pre>
251  Those specifying line ending sequences are literal strings as shown, but the  The modifiers that are enclosed in angle brackets are literal strings as shown,
252  letters can be in either case. This example sets multiline matching with CRLF  including the angle brackets, but the letters within can be in either case.
253  as the line ending sequence:  This example sets multiline matching with CRLF as the line ending sequence:
254  <pre>  <pre>
255    /^abc/m&#60;crlf&#62;    /^abc/m&#60;CRLF&#62;
256  </pre>  </pre>
257  Details of the meanings of these PCRE options are given in the  As well as turning on the PCRE_UTF8 option, the <b>/8</b> modifier also causes
258    any non-printing characters in output strings to be printed using the
259    \x{hh...} notation if they are valid UTF-8 sequences. Full details of the PCRE
260    options are given in the
261  <a href="pcreapi.html"><b>pcreapi</b></a>  <a href="pcreapi.html"><b>pcreapi</b></a>
262  documentation.  documentation.
263  </P>  </P>
# Line 248  begins with a lookbehind assertion (incl Line 278  begins with a lookbehind assertion (incl
278  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
279  empty string, the next call is done with the PCRE_NOTEMPTY_ATSTART and  empty string, the next call is done with the PCRE_NOTEMPTY_ATSTART and
280  PCRE_ANCHORED flags set in order to search for another, non-empty, match at the  PCRE_ANCHORED flags set in order to search for another, non-empty, match at the
281  same point. If this second match fails, the start offset is advanced by one  same point. If this second match fails, the start offset is advanced, and the
282  character, and the normal match is retried. This imitates the way Perl handles  normal match is retried. This imitates the way Perl handles such cases when
283  such cases when using the <b>/g</b> modifier or the <b>split()</b> function.  using the <b>/g</b> modifier or the <b>split()</b> function. Normally, the start
284    offset is advanced by one character, but if the newline convention recognizes
285    CRLF as a newline, and the current character is CR followed by LF, an advance
286    of two is used.
287  </P>  </P>
288  <br><b>  <br><b>
289  Other modifiers  Other modifiers
# Line 260  There are yet more modifiers for control Line 293  There are yet more modifiers for control
293  operates.  operates.
294  </P>  </P>
295  <P>  <P>
 The <b>/8</b> modifier causes <b>pcretest</b> to call PCRE with the PCRE_UTF8  
 option set. This turns on support for UTF-8 character handling in PCRE,  
 provided that it was compiled with this support enabled. This modifier also  
 causes any non-printing characters in output strings to be printed using the  
 \x{hh...} notation if they are valid UTF-8 sequences.  
 </P>  
 <P>  
 If the <b>/?</b> modifier is used with <b>/8</b>, it causes <b>pcretest</b> to  
 call <b>pcre_compile()</b> with the PCRE_NO_UTF8_CHECK option, to suppress the  
 checking of the string for UTF-8 validity.  
 </P>  
 <P>  
296  The <b>/+</b> modifier requests that as well as outputting the substring that  The <b>/+</b> modifier requests that as well as outputting the substring that
297  matched the entire pattern, pcretest should in addition output the remainder of  matched the entire pattern, <b>pcretest</b> should in addition output the
298  the subject string. This is useful for tests where the subject contains  remainder of the subject string. This is useful for tests where the subject
299  multiple copies of the same substring.  contains multiple copies of the same substring. If the <b>+</b> modifier appears
300    twice, the same action is taken for captured substrings. In each case the
301    remainder is output on the following line with a plus character following the
302    capture number. Note that this modifier must not immediately follow the /S
303    modifier because /S+ has another meaning.
304    </P>
305    <P>
306    The <b>/=</b> modifier requests that the values of all potential captured
307    parentheses be output after a match by <b>pcre_exec()</b>. By default, only
308    those up to the highest one actually used in the match are output
309    (corresponding to the return code from <b>pcre_exec()</b>). Values in the
310    offsets vector corresponding to higher numbers should be set to -1, and these
311    are output as "&#60;unset&#62;". This modifier gives a way of checking that this is
312    happening.
313  </P>  </P>
314  <P>  <P>
315  The <b>/B</b> modifier is a debugging feature. It requests that <b>pcretest</b>  The <b>/B</b> modifier is a debugging feature. It requests that <b>pcretest</b>
# Line 324  example, Line 358  example,
358  For this reason, it must be the last modifier. The given locale is set,  For this reason, it must be the last modifier. The given locale is set,
359  <b>pcre_maketables()</b> is called to build a set of character tables for the  <b>pcre_maketables()</b> is called to build a set of character tables for the
360  locale, and this is then passed to <b>pcre_compile()</b> when compiling the  locale, and this is then passed to <b>pcre_compile()</b> when compiling the
361  regular expression. Without an <b>/L</b> modifier, NULL is passed as the tables  regular expression. Without an <b>/L</b> (or <b>/T</b>) modifier, NULL is passed
362  pointer; that is, <b>/L</b> applies only to the expression on which it appears.  as the tables pointer; that is, <b>/L</b> applies only to the expression on
363    which it appears.
364  </P>  </P>
365  <P>  <P>
366  The <b>/M</b> modifier causes the size of memory block used to hold the compiled  The <b>/M</b> modifier causes the size of memory block used to hold the compiled
367  pattern to be output.  pattern to be output. This does not include the size of the <b>pcre</b> block;
368    it is just the actual compiled data. If the pattern is successfully studied
369    with the PCRE_STUDY_JIT_COMPILE option, the size of the JIT compiled code is
370    also output.
371    </P>
372    <P>
373    If the <b>/S</b> modifier appears once, it causes <b>pcre_study()</b> to be
374    called after the expression has been compiled, and the results used when the
375    expression is matched. If <b>/S</b> appears twice, it suppresses studying, even
376    if it was requested externally by the <b>-s</b> command line option. This makes
377    it possible to specify that certain patterns are always studied, and others are
378    never studied, independently of <b>-s</b>. This feature is used in the test
379    files in a few cases where the output is different when the pattern is studied.
380    </P>
381    <P>
382    If the <b>/S</b> modifier is immediately followed by a + character, the call to
383    <b>pcre_study()</b> is made with the PCRE_STUDY_JIT_COMPILE option, requesting
384    just-in-time optimization support if it is available. Note that there is also a
385    <b>/+</b> modifier; it must not be given immediately after <b>/S</b> because this
386    will be misinterpreted. If JIT studying is successful, it will automatically be
387    used when <b>pcre_exec()</b> is run, except when incompatible run-time options
388    are specified. These include the partial matching options; a complete list is
389    given in the
390    <a href="pcrejit.html"><b>pcrejit</b></a>
391    documentation. See also the <b>\J</b> escape sequence below for a way of
392    setting the size of the JIT stack.
393    </P>
394    <P>
395    The <b>/T</b> modifier must be followed by a single digit. It causes a specific
396    set of built-in character tables to be passed to <b>pcre_compile()</b>. It is
397    used in the standard PCRE tests to check behaviour with different character
398    tables. The digit specifies the tables as follows:
399    <pre>
400      0   the default ASCII tables, as distributed in
401            pcre_chartables.c.dist
402      1   a set of tables defining ISO 8859 characters
403    </pre>
404    In table 1, some characters whose codes are greater than 128 are identified as
405    letters, digits, spaces, etc.
406  </P>  </P>
407    <br><b>
408    Using the POSIX wrapper API
409    </b><br>
410  <P>  <P>
411  The <b>/P</b> modifier causes <b>pcretest</b> to call PCRE via the POSIX wrapper  The <b>/P</b> modifier causes <b>pcretest</b> to call PCRE via the POSIX wrapper
412  API rather than its native API. When this is done, all other modifiers except  API rather than its native API. When <b>/P</b> is set, the following modifiers
413  <b>/i</b>, <b>/m</b>, and <b>/+</b> are ignored. REG_ICASE is set if <b>/i</b> is  set options for the <b>regcomp()</b> function:
414  present, and REG_NEWLINE is set if <b>/m</b> is present. The wrapper functions  <pre>
415  force PCRE_DOLLAR_ENDONLY always, and PCRE_DOTALL unless REG_NEWLINE is set.    /i    REG_ICASE
416  </P>    /m    REG_NEWLINE
417  <P>    /N    REG_NOSUB
418  The <b>/S</b> modifier causes <b>pcre_study()</b> to be called after the    /s    REG_DOTALL     )
419  expression has been compiled, and the results used when the expression is    /U    REG_UNGREEDY   ) These options are not part of
420  matched.    /W    REG_UCP        )   the POSIX standard
421      /8    REG_UTF8       )
422    </pre>
423    The <b>/+</b> modifier works as described above. All other modifiers are
424    ignored.
425  </P>  </P>
426  <br><a name="SEC5" href="#TOC1">DATA LINES</a><br>  <br><a name="SEC5" href="#TOC1">DATA LINES</a><br>
427  <P>  <P>
428  Before each data line is passed to <b>pcre_exec()</b>, leading and trailing  Before each data line is passed to <b>pcre_exec()</b>, leading and trailing
429  whitespace is removed, and it is then scanned for \ escapes. Some of these are  white space is removed, and it is then scanned for \ escapes. Some of these
430  pretty esoteric features, intended for checking out some of the more  are pretty esoteric features, intended for checking out some of the more
431  complicated features of PCRE. If you are just testing "ordinary" regular  complicated features of PCRE. If you are just testing "ordinary" regular
432  expressions, you probably don't need any of these. The following escapes are  expressions, you probably don't need any of these. The following escapes are
433  recognized:  recognized:
# Line 355  recognized: Line 435  recognized:
435    \a         alarm (BEL, \x07)    \a         alarm (BEL, \x07)
436    \b         backspace (\x08)    \b         backspace (\x08)
437    \e         escape (\x27)    \e         escape (\x27)
438    \f         formfeed (\x0c)    \f         form feed (\x0c)
439    \n         newline (\x0a)    \n         newline (\x0a)
440    \qdd       set the PCRE_MATCH_LIMIT limit to dd (any number of digits)    \qdd       set the PCRE_MATCH_LIMIT limit to dd (any number of digits)
441    \r         carriage return (\x0d)    \r         carriage return (\x0d)
442    \t         tab (\x09)    \t         tab (\x09)
443    \v         vertical tab (\x0b)    \v         vertical tab (\x0b)
444    \nnn       octal character (up to 3 octal digits)    \nnn       octal character (up to 3 octal digits)
445    \xhh       hexadecimal character (up to 2 hex digits)                 always a byte unless &#62; 255 in UTF-8 mode
446      \xhh       hexadecimal byte (up to 2 hex digits)
447    \x{hh...}  hexadecimal character, any number of digits in UTF-8 mode    \x{hh...}  hexadecimal character, any number of digits in UTF-8 mode
448    \A         pass the PCRE_ANCHORED option to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>    \A         pass the PCRE_ANCHORED option to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>
449    \B         pass the PCRE_NOTBOL option to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>    \B         pass the PCRE_NOTBOL option to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>
# Line 379  recognized: Line 460  recognized:
460    \Gdd       call pcre_get_substring() for substring dd after a successful match (number less than 32)    \Gdd       call pcre_get_substring() for substring dd after a successful match (number less than 32)
461    \Gname     call pcre_get_named_substring() for substring "name" after a successful match (name termin-    \Gname     call pcre_get_named_substring() for substring "name" after a successful match (name termin-
462                 ated by next non-alphanumeric character)                 ated by next non-alphanumeric character)
463      \Jdd       set up a JIT stack of dd kilobytes maximum (any number of digits)
464    \L         call pcre_get_substringlist() after a successful match    \L         call pcre_get_substringlist() after a successful match
465    \M         discover the minimum MATCH_LIMIT and MATCH_LIMIT_RECURSION settings    \M         discover the minimum MATCH_LIMIT and MATCH_LIMIT_RECURSION settings
466    \N         pass the PCRE_NOTEMPTY option to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>; if used twice, pass the    \N         pass the PCRE_NOTEMPTY option to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>; if used twice, pass the
# Line 392  recognized: Line 474  recognized:
474    \Y         pass the PCRE_NO_START_OPTIMIZE option to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>    \Y         pass the PCRE_NO_START_OPTIMIZE option to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>
475    \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>
476    \?         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>
477    \&#62;dd       start the match at offset dd (any number of digits);    \&#62;dd       start the match at offset dd (optional "-"; then any number of digits); this sets the <i>startoffset</i>
478                 this sets the <i>startoffset</i> argument for <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>                 argument for <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>
479    \&#60;cr&#62;      pass the PCRE_NEWLINE_CR option to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>    \&#60;cr&#62;      pass the PCRE_NEWLINE_CR option to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>
480    \&#60;lf&#62;      pass the PCRE_NEWLINE_LF option to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>    \&#60;lf&#62;      pass the PCRE_NEWLINE_LF option to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>
481    \&#60;crlf&#62;    pass the PCRE_NEWLINE_CRLF option to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>    \&#60;crlf&#62;    pass the PCRE_NEWLINE_CRLF option to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>
482    \&#60;anycrlf&#62; pass the PCRE_NEWLINE_ANYCRLF option to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>    \&#60;anycrlf&#62; pass the PCRE_NEWLINE_ANYCRLF option to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>
483    \&#60;any&#62;     pass the PCRE_NEWLINE_ANY option to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>    \&#60;any&#62;     pass the PCRE_NEWLINE_ANY option to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>
484  </pre>  </pre>
485    Note that \xhh always specifies one byte, even in UTF-8 mode; this makes it
486    possible to construct invalid UTF-8 sequences for testing purposes. On the
487    other hand, \x{hh} is interpreted as a UTF-8 character in UTF-8 mode,
488    generating more than one byte if the value is greater than 127. When not in
489    UTF-8 mode, it generates one byte for values less than 256, and causes an error
490    for greater values.
491    </P>
492    <P>
493  The escapes that specify line ending sequences are literal strings, exactly as  The escapes that specify line ending sequences are literal strings, exactly as
494  shown. No more than one newline setting should be present in any data line.  shown. No more than one newline setting should be present in any data line.
495  </P>  </P>
# Line 410  passing an empty line as data, since a r Line 500  passing an empty line as data, since a r
500  input.  input.
501  </P>  </P>
502  <P>  <P>
503    The <b>\J</b> escape provides a way of setting the maximum stack size that is
504    used by the just-in-time optimization code. It is ignored if JIT optimization
505    is not being used. Providing a stack that is larger than the default 32K is
506    necessary only for very complicated patterns.
507    </P>
508    <P>
509  If \M is present, <b>pcretest</b> calls <b>pcre_exec()</b> several times, with  If \M is present, <b>pcretest</b> calls <b>pcre_exec()</b> several times, with
510  different values in the <i>match_limit</i> and <i>match_limit_recursion</i>  different values in the <i>match_limit</i> and <i>match_limit_recursion</i>
511  fields of the <b>pcre_extra</b> data structure, until it finds the minimum  fields of the <b>pcre_extra</b> data structure, until it finds the minimum
512  numbers for each parameter that allow <b>pcre_exec()</b> to complete. The  numbers for each parameter that allow <b>pcre_exec()</b> to complete without
513  <i>match_limit</i> number is a measure of the amount of backtracking that takes  error. Because this is testing a specific feature of the normal interpretive
514  place, and checking it out can be instructive. For most simple matches, the  <b>pcre_exec()</b> execution, the use of any JIT optimization that might have
515  number is quite small, but for patterns with very large numbers of matching  been set up by the <b>/S+</b> qualifier of <b>-s+</b> option is disabled.
516  possibilities, it can become large very quickly with increasing length of  </P>
517  subject string. The <i>match_limit_recursion</i> number is a measure of how much  <P>
518  stack (or, if PCRE is compiled with NO_RECURSE, how much heap) memory is needed  The <i>match_limit</i> number is a measure of the amount of backtracking
519  to complete the match attempt.  that takes place, and checking it out can be instructive. For most simple
520    matches, the number is quite small, but for patterns with very large numbers of
521    matching possibilities, it can become large very quickly with increasing length
522    of subject string. The <i>match_limit_recursion</i> number is a measure of how
523    much stack (or, if PCRE is compiled with NO_RECURSE, how much heap) memory is
524    needed to complete the match attempt.
525  </P>  </P>
526  <P>  <P>
527  When \O is used, the value specified may be higher or lower than the size set  When \O is used, the value specified may be higher or lower than the size set
# Line 429  the call of <b>pcre_exec()</b> for the l Line 530  the call of <b>pcre_exec()</b> for the l
530  </P>  </P>
531  <P>  <P>
532  If the <b>/P</b> modifier was present on the pattern, causing the POSIX wrapper  If the <b>/P</b> modifier was present on the pattern, causing the POSIX wrapper
533  API to be used, the only option-setting sequences that have any effect are \B  API to be used, the only option-setting sequences that have any effect are \B,
534  and \Z, causing REG_NOTBOL and REG_NOTEOL, respectively, to be passed to  \N, and \Z, causing REG_NOTBOL, REG_NOTEMPTY, and REG_NOTEOL, respectively,
535  <b>regexec()</b>.  to be passed to <b>regexec()</b>.
536  </P>  </P>
537  <P>  <P>
538  The use of \x{hh...} to represent UTF-8 characters is not dependent on the use  The use of \x{hh...} to represent UTF-8 characters is not dependent on the use
# Line 465  This section describes the output when t Line 566  This section describes the output when t
566  <b>pcre_exec()</b>, is being used.  <b>pcre_exec()</b>, is being used.
567  </P>  </P>
568  <P>  <P>
569  When a match succeeds, pcretest outputs the list of captured substrings that  When a match succeeds, <b>pcretest</b> outputs the list of captured substrings
570  <b>pcre_exec()</b> returns, starting with number 0 for the string that matched  that <b>pcre_exec()</b> returns, starting with number 0 for the string that
571  the whole pattern. Otherwise, it outputs "No match" when the return is  matched the whole pattern. Otherwise, it outputs "No match" when the return is
572  PCRE_ERROR_NOMATCH, and "Partial match:" followed by the partially matching  PCRE_ERROR_NOMATCH, and "Partial match:" followed by the partially matching
573  substring when <b>pcre_exec()</b> returns PCRE_ERROR_PARTIAL. For any other  substring when <b>pcre_exec()</b> returns PCRE_ERROR_PARTIAL. (Note that this is
574  returns, it outputs the PCRE negative error number. Here is an example of an  the entire substring that was inspected during the partial match; it may
575  interactive <b>pcretest</b> run.  include characters before the actual match start if a lookbehind assertion,
576    \K, \b, or \B was involved.) For any other return, <b>pcretest</b> outputs
577    the PCRE negative error number and a short descriptive phrase. If the error is
578    a failed UTF-8 string check, the byte offset of the start of the failing
579    character and the reason code are also output, provided that the size of the
580    output vector is at least two. Here is an example of an interactive
581    <b>pcretest</b> run.
582  <pre>  <pre>
583    $ pcretest    $ pcretest
584    PCRE version 7.0 30-Nov-2006    PCRE version 8.13 2011-04-30
585    
586      re&#62; /^abc(\d+)/      re&#62; /^abc(\d+)/
587    data&#62; abc123    data&#62; abc123
# Line 483  interactive <b>pcretest</b> run. Line 590  interactive <b>pcretest</b> run.
590    data&#62; xyz    data&#62; xyz
591    No match    No match
592  </pre>  </pre>
593  Note that unset capturing substrings that are not followed by one that is set  Unset capturing substrings that are not followed by one that is set are not
594  are not returned by <b>pcre_exec()</b>, and are not shown by <b>pcretest</b>. In  returned by <b>pcre_exec()</b>, and are not shown by <b>pcretest</b>. In the
595  the following example, there are two capturing substrings, but when the first  following example, there are two capturing substrings, but when the first data
596  data line is matched, the second, unset substring is not shown. An "internal"  line is matched, the second, unset substring is not shown. An "internal" unset
597  unset substring is shown as "&#60;unset&#62;", as for the second data line.  substring is shown as "&#60;unset&#62;", as for the second data line.
598  <pre>  <pre>
599      re&#62; /(a)|(b)/      re&#62; /(a)|(b)/
600    data&#62; a    data&#62; a
# Line 521  matching attempts are output in sequence Line 628  matching attempts are output in sequence
628     0: ipp     0: ipp
629     1: pp     1: pp
630  </pre>  </pre>
631  "No match" is output only if the first match attempt fails.  "No match" is output only if the first match attempt fails. Here is an example
632    of a failure message (the offset 4 that is specified by \&#62;4 is past the end of
633    the subject string):
634    <pre>
635        re&#62; /xyz/
636      data&#62; xyz\&#62;4
637      Error -24 (bad offset value)
638    </PRE>
639  </P>  </P>
640  <P>  <P>
641  If any of the sequences <b>\C</b>, <b>\G</b>, or <b>\L</b> are present in a  If any of the sequences <b>\C</b>, <b>\G</b>, or <b>\L</b> are present in a
# Line 553  the subject where there is at least one Line 667  the subject where there is at least one
667  (Using the normal matching function on this data finds only "tang".) The  (Using the normal matching function on this data finds only "tang".) The
668  longest matching string is always given first (and numbered zero). After a  longest matching string is always given first (and numbered zero). After a
669  PCRE_ERROR_PARTIAL return, the output is "Partial match:", followed by the  PCRE_ERROR_PARTIAL return, the output is "Partial match:", followed by the
670  partially matching substring.  partially matching substring. (Note that this is the entire substring that was
671    inspected during the partial match; it may include characters before the actual
672    match start if a lookbehind assertion, \K, \b, or \B was involved.)
673  </P>  </P>
674  <P>  <P>
675  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
# Line 619  example: Line 735  example:
735    +10 ^ ^    +10 ^ ^
736     0: E*     0: E*
737  </pre>  </pre>
738    If a pattern contains (*MARK) items, an additional line is output whenever
739    a change of latest mark is passed to the callout function. For example:
740    <pre>
741        re&#62; /a(*MARK:X)bc/C
742      data&#62; abc
743      ---&#62;abc
744       +0 ^       a
745       +1 ^^      (*MARK:X)
746      +10 ^^      b
747      Latest Mark: X
748      +11 ^ ^     c
749      +12 ^  ^
750       0: abc
751    </pre>
752    The mark changes between matching "a" and "b", but stays the same for the rest
753    of the match, so nothing more is output. If, as a result of backtracking, the
754    mark reverts to being unset, the text "&#60;unset&#62;" is output.
755    </P>
756    <P>
757  The callout function in <b>pcretest</b> returns zero (carry on matching) by  The callout function in <b>pcretest</b> returns zero (carry on matching) by
758  default, but you can use a \C item in a data line (as described above) to  default, but you can use a \C item in a data line (as described above) to
759  change this.  change this and other parameters of the callout.
760  </P>  </P>
761  <P>  <P>
762  Inserting callouts can be helpful when using <b>pcretest</b> to check  Inserting callouts can be helpful when using <b>pcretest</b> to check
# Line 645  function to distinguish printing and non Line 780  function to distinguish printing and non
780  <br><a name="SEC12" href="#TOC1">SAVING AND RELOADING COMPILED PATTERNS</a><br>  <br><a name="SEC12" href="#TOC1">SAVING AND RELOADING COMPILED PATTERNS</a><br>
781  <P>  <P>
782  The facilities described in this section are not available when the POSIX  The facilities described in this section are not available when the POSIX
783  inteface to PCRE is being used, that is, when the <b>/P</b> pattern modifier is  interface to PCRE is being used, that is, when the <b>/P</b> pattern modifier is
784  specified.  specified.
785  </P>  </P>
786  <P>  <P>
# Line 658  For example: Line 793  For example:
793  See the  See the
794  <a href="pcreprecompile.html"><b>pcreprecompile</b></a>  <a href="pcreprecompile.html"><b>pcreprecompile</b></a>
795  documentation for a discussion about saving and re-using compiled patterns.  documentation for a discussion about saving and re-using compiled patterns.
796    Note that if the pattern was successfully studied with JIT optimization, the
797    JIT data cannot be saved.
798  </P>  </P>
799  <P>  <P>
800  The data that is written is binary. The first eight bytes are the length of the  The data that is written is binary. The first eight bytes are the length of the
# Line 666  written as four bytes in big-endian orde Line 803  written as four bytes in big-endian orde
803  there is no study data (either the pattern was not studied, or studying did not  there is no study data (either the pattern was not studied, or studying did not
804  return any data), the second length is zero. The lengths are followed by an  return any data), the second length is zero. The lengths are followed by an
805  exact copy of the compiled pattern. If there is additional study data, this  exact copy of the compiled pattern. If there is additional study data, this
806  follows immediately after the compiled pattern. After writing the file,  (excluding any JIT data) follows immediately after the compiled pattern. After
807  <b>pcretest</b> expects to read a new pattern.  writing the file, <b>pcretest</b> expects to read a new pattern.
808  </P>  </P>
809  <P>  <P>
810  A saved pattern can be reloaded into <b>pcretest</b> by specifing &#60; and a file  A saved pattern can be reloaded into <b>pcretest</b> by specifying &#60; and a file
811  name instead of a pattern. The name of the file must not contain a &#60; character,  name instead of a pattern. The name of the file must not contain a &#60; character,
812  as otherwise <b>pcretest</b> will interpret the line as a pattern delimited by &#60;  as otherwise <b>pcretest</b> will interpret the line as a pattern delimited by &#60;
813  characters.  characters.
814  For example:  For example:
815  <pre>  <pre>
816     re&#62; &#60;/some/file     re&#62; &#60;/some/file
817    Compiled regex loaded from /some/file    Compiled pattern loaded from /some/file
818    No study data    No study data
819  </pre>  </pre>
820  When the pattern has been loaded, <b>pcretest</b> proceeds to read data lines in  If the pattern was previously studied with the JIT optimization, the JIT
821  the usual way.  information cannot be saved and restored, and so is lost. When the pattern has
822    been loaded, <b>pcretest</b> proceeds to read data lines in the usual way.
823  </P>  </P>
824  <P>  <P>
825  You can copy a file written by <b>pcretest</b> to a different host and reload it  You can copy a file written by <b>pcretest</b> to a different host and reload it
# Line 706  result is undefined. Line 844  result is undefined.
844  </P>  </P>
845  <br><a name="SEC13" href="#TOC1">SEE ALSO</a><br>  <br><a name="SEC13" href="#TOC1">SEE ALSO</a><br>
846  <P>  <P>
847  <b>pcre</b>(3), <b>pcreapi</b>(3), <b>pcrecallout</b>(3), <b>pcrematching</b>(3),  <b>pcre</b>(3), <b>pcreapi</b>(3), <b>pcrecallout</b>(3), <b>pcrejit</b>,
848  <b>pcrepartial</b>(d), <b>pcrepattern</b>(3), <b>pcreprecompile</b>(3).  <b>pcrematching</b>(3), <b>pcrepartial</b>(d), <b>pcrepattern</b>(3),
849    <b>pcreprecompile</b>(3).
850  </P>  </P>
851  <br><a name="SEC14" href="#TOC1">AUTHOR</a><br>  <br><a name="SEC14" href="#TOC1">AUTHOR</a><br>
852  <P>  <P>
# Line 720  Cambridge CB2 3QH, England. Line 859  Cambridge CB2 3QH, England.
859  </P>  </P>
860  <br><a name="SEC15" href="#TOC1">REVISION</a><br>  <br><a name="SEC15" href="#TOC1">REVISION</a><br>
861  <P>  <P>
862  Last updated: 26 March 2010  Last updated: 02 December 2011
863  <br>  <br>
864  Copyright &copy; 1997-2010 University of Cambridge.  Copyright &copy; 1997-2011 University of Cambridge.
865  <br>  <br>
866  <p>  <p>
867  Return to the <a href="index.html">PCRE index page</a>.  Return to the <a href="index.html">PCRE index page</a>.

Legend:
Removed from v.512  
changed lines
  Added in v.836

  ViewVC Help
Powered by ViewVC 1.1.5