/[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 75 by nigel, Sat Feb 24 21:40:37 2007 UTC revision 545 by ph10, Wed Jun 16 10:51:15 2010 UTC
# Line 18  man page, in case the conversion went wr Line 18  man page, in case the conversion went wr
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>
21  <li><a name="TOC6" href="#SEC6">OUTPUT FROM PCRETEST</a>  <li><a name="TOC6" href="#SEC6">THE ALTERNATIVE MATCHING FUNCTION</a>
22  <li><a name="TOC7" href="#SEC7">CALLOUTS</a>  <li><a name="TOC7" href="#SEC7">DEFAULT OUTPUT FROM PCRETEST</a>
23  <li><a name="TOC8" href="#SEC8">SAVING AND RELOADING COMPILED PATTERNS</a>  <li><a name="TOC8" href="#SEC8">OUTPUT FROM THE ALTERNATIVE MATCHING FUNCTION</a>
24  <li><a name="TOC9" href="#SEC9">AUTHOR</a>  <li><a name="TOC9" href="#SEC9">RESTARTING AFTER A PARTIAL MATCH</a>
25    <li><a name="TOC10" href="#SEC10">CALLOUTS</a>
26    <li><a name="TOC11" href="#SEC11">NON-PRINTING CHARACTERS</a>
27    <li><a name="TOC12" href="#SEC12">SAVING AND RELOADING COMPILED PATTERNS</a>
28    <li><a name="TOC13" href="#SEC13">SEE ALSO</a>
29    <li><a name="TOC14" href="#SEC14">AUTHOR</a>
30    <li><a name="TOC15" href="#SEC15">REVISION</a>
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 [-C] [-d] [-i] [-m] [-o osize] [-p] [-t] [source]</b>  <b>pcretest [options] [source] [destination]</b>
35  <b>[destination]</b>  <br>
36  </P>  <br>
 <P>  
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
38  library itself, but it can also be used for experimenting with regular  library itself, but it can also be used for experimenting with regular
39  expressions. This document describes the features of the test program; for  expressions. This document describes the features of the test program; for
# Line 41  documentation. Line 46  documentation.
46  </P>  </P>
47  <br><a name="SEC2" href="#TOC1">OPTIONS</a><br>  <br><a name="SEC2" href="#TOC1">OPTIONS</a><br>
48  <P>  <P>
49    <b>-b</b>
50    Behave as if each regex has the <b>/B</b> (show bytecode) modifier; the internal
51    form is output after compilation.
52    </P>
53    <P>
54  <b>-C</b>  <b>-C</b>
55  Output the version number of the PCRE library, and all available information  Output the version number of the PCRE library, and all available information
56  about the optional features that are included, and then exit.  about the optional features that are included, and then exit.
57  </P>  </P>
58  <P>  <P>
59  <b>-d</b>  <b>-d</b>
60  Behave as if each regex had the <b>/D</b> (debug) modifier; the internal  Behave as if each regex has the <b>/D</b> (debug) modifier; the internal
61  form is output after compilation.  form and information about the compiled pattern is output after compilation;
62    <b>-d</b> is equivalent to <b>-b -i</b>.
63    </P>
64    <P>
65    <b>-dfa</b>
66    Behave as if each data line contains the \D escape sequence; this causes the
67    alternative matching function, <b>pcre_dfa_exec()</b>, to be used instead of the
68    standard <b>pcre_exec()</b> function (more detail is given below).
69    </P>
70    <P>
71    <b>-help</b>
72    Output a brief summary these options and then exit.
73  </P>  </P>
74  <P>  <P>
75  <b>-i</b>  <b>-i</b>
76  Behave as if each regex had the <b>/I</b> modifier; information about the  Behave as if each regex has the <b>/I</b> modifier; information about the
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
# Line 64  with earlier versions of pcretest, <b>-s Line 91  with earlier versions of pcretest, <b>-s
91  <P>  <P>
92  <b>-o</b> <i>osize</i>  <b>-o</b> <i>osize</i>
93  Set the number of elements in the output vector that is used when calling  Set the number of elements in the output vector that is used when calling
94  <b>pcre_exec()</b> to be <i>osize</i>. The default value is 45, which is enough  <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b> to be <i>osize</i>. The default value
95  for 14 capturing subexpressions. The vector size can be changed for individual  is 45, which is enough for 14 capturing subexpressions for <b>pcre_exec()</b> or
96  matching calls by including \O in the data line (see below).  22 different matches for <b>pcre_dfa_exec()</b>. The vector size can be
97    changed for individual matching calls by including \O in the data line (see
98    below).
99  </P>  </P>
100  <P>  <P>
101  <b>-p</b>  <b>-p</b>
102  Behave as if each regex has <b>/P</b> modifier; the POSIX wrapper API is used  Behave as if each regex has the <b>/P</b> modifier; the POSIX wrapper API is
103  to call PCRE. None of the other options has any effect when <b>-p</b> is set.  used to call PCRE. None of the other options has any effect when <b>-p</b> is
104    set.
105    </P>
106    <P>
107    <b>-q</b>
108    Do not output the version number of <b>pcretest</b> at the start of execution.
109    </P>
110    <P>
111    <b>-S</b> <i>size</i>
112    On Unix-like systems, set the size of the runtime stack to <i>size</i>
113    megabytes.
114  </P>  </P>
115  <P>  <P>
116  <b>-t</b>  <b>-t</b>
117  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
118  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
119  <b>-t</b>, because you will then get the size output a zillion times, and the  <b>-t</b>, because you will then get the size output a zillion times, and the
120  timing will be distorted.  timing will be distorted. You can control the number of iterations that are
121    used for timing by following <b>-t</b> with a number (as a separate item on the
122    command line). For example, "-t 1000" would iterate 1000 times. The default is
123    to iterate 500000 times.
124    </P>
125    <P>
126    <b>-tm</b>
127    This is like <b>-t</b> except that it times only the matching phase, not the
128    compile or study phases.
129  </P>  </P>
130  <br><a name="SEC3" href="#TOC1">DESCRIPTION</a><br>  <br><a name="SEC3" href="#TOC1">DESCRIPTION</a><br>
131  <P>  <P>
# Line 89  stdout, and prompts for each line of inp Line 136  stdout, and prompts for each line of inp
136  expressions, and "data&#62;" to prompt for data lines.  expressions, and "data&#62;" 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.
149  </P>  </P>
150  <P>  <P>
151  Each data line is matched separately and independently. If you want to do  Each data line is matched separately and independently. If you want to do
152  multiple-line matches, you have to use the \n escape sequence in a single line  multi-line matches, you have to use the \n escape sequence (or \r or \r\n,
153  of input to encode the newline characters. The maximum length of data line is  etc., depending on the newline setting) in a single line of input to encode the
154  30,000 characters.  newline sequences. There is no limit on the length of data lines; the input
155    buffer is automatically extended if it is too small.
156  </P>  </P>
157  <P>  <P>
158  An empty line signals the end of the data lines, at which point a new regular  An empty line signals the end of the data lines, at which point a new regular
159  expression is read. The regular expressions are given enclosed in any  expression is read. The regular expressions are given enclosed in any
160  non-alphanumeric delimiters other than backslash, for example  non-alphanumeric delimiters other than backslash, for example:
161  <pre>  <pre>
162    /(a|bc)x+yz/    /(a|bc)x+yz/
163  </pre>  </pre>
# Line 146  effect as they do in Perl. For example: Line 201  effect as they do in Perl. For example:
201  <pre>  <pre>
202    /caseless/i    /caseless/i
203  </pre>  </pre>
204  The following table shows additional modifiers for setting PCRE options that do  The following table shows additional modifiers for setting PCRE compile-time
205  not correspond to anything in Perl:  options that do not correspond to anything in Perl:
206  <pre>  <pre>
207    <b>/A</b>    PCRE_ANCHORED    <b>/8</b>              PCRE_UTF8
208    <b>/C</b>    PCRE_AUTO_CALLOUT    <b>/?</b>              PCRE_NO_UTF8_CHECK
209    <b>/E</b>    PCRE_DOLLAR_ENDONLY    <b>/A</b>              PCRE_ANCHORED
210    <b>/N</b>    PCRE_NO_AUTO_CAPTURE    <b>/C</b>              PCRE_AUTO_CALLOUT
211    <b>/U</b>    PCRE_UNGREEDY    <b>/E</b>              PCRE_DOLLAR_ENDONLY
212    <b>/X</b>    PCRE_EXTRA    <b>/f</b>              PCRE_FIRSTLINE
213  </pre>    <b>/J</b>              PCRE_DUPNAMES
214      <b>/N</b>              PCRE_NO_AUTO_CAPTURE
215      <b>/U</b>              PCRE_UNGREEDY
216      <b>/W</b>              PCRE_UCP
217      <b>/X</b>              PCRE_EXTRA
218      <b>/&#60;JS&#62;</b>           PCRE_JAVASCRIPT_COMPAT
219      <b>/&#60;cr&#62;</b>           PCRE_NEWLINE_CR
220      <b>/&#60;lf&#62;</b>           PCRE_NEWLINE_LF
221      <b>/&#60;crlf&#62;</b>         PCRE_NEWLINE_CRLF
222      <b>/&#60;anycrlf&#62;</b>      PCRE_NEWLINE_ANYCRLF
223      <b>/&#60;any&#62;</b>          PCRE_NEWLINE_ANY
224      <b>/&#60;bsr_anycrlf&#62;</b>  PCRE_BSR_ANYCRLF
225      <b>/&#60;bsr_unicode&#62;</b>  PCRE_BSR_UNICODE
226    </pre>
227    The modifiers that are enclosed in angle brackets are literal strings as shown,
228    including the angle brackets, but the letters can be in either case. This
229    example sets multiline matching with CRLF as the line ending sequence:
230    <pre>
231      /^abc/m&#60;crlf&#62;
232    </pre>
233    As well as turning on the PCRE_UTF8 option, the <b>/8</b> modifier also causes
234    any non-printing characters in output strings to be printed using the
235    \x{hh...} notation if they are valid UTF-8 sequences. Full details of the PCRE
236    options are given in the
237    <a href="pcreapi.html"><b>pcreapi</b></a>
238    documentation.
239    </P>
240    <br><b>
241    Finding all matches in a string
242    </b><br>
243    <P>
244  Searching for all possible matches within each subject string can be requested  Searching for all possible matches within each subject string can be requested
245  by the <b>/g</b> or <b>/G</b> modifier. After finding a match, PCRE is called  by the <b>/g</b> or <b>/G</b> modifier. After finding a match, PCRE is called
246  again to search the remainder of the subject string. The difference between  again to search the remainder of the subject string. The difference between
# Line 167  begins with a lookbehind assertion (incl Line 252  begins with a lookbehind assertion (incl
252  </P>  </P>
253  <P>  <P>
254  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
255  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
256  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
257  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
258  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
259  <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.
260  </P>  </P>
261    <br><b>
262    Other modifiers
263    </b><br>
264  <P>  <P>
265  There are yet more modifiers for controlling the way <b>pcretest</b>  There are yet more modifiers for controlling the way <b>pcretest</b>
266  operates.  operates.
# Line 184  the subject string. This is useful for t Line 272  the subject string. This is useful for t
272  multiple copies of the same substring.  multiple copies of the same substring.
273  </P>  </P>
274  <P>  <P>
275  The <b>/L</b> modifier must be followed directly by the name of a locale, for  The <b>/B</b> modifier is a debugging feature. It requests that <b>pcretest</b>
276  example,  output a representation of the compiled byte code after compilation. Normally
277  <pre>  this information contains length and offset values; however, if <b>/Z</b> is
278    /pattern/Lfr_FR  also present, this data is replaced by spaces. This is a special feature for
279  </pre>  use in the automatic test scripts; it ensures that the same output is generated
280  For this reason, it must be the last modifier. The given locale is set,  for different internal link sizes.
 <b>pcre_maketables()</b> is called to build a set of character tables for the  
 locale, and this is then passed to <b>pcre_compile()</b> when compiling the  
 regular expression. Without an <b>/L</b> modifier, NULL is passed as the tables  
 pointer; that is, <b>/L</b> applies only to the expression on which it appears.  
281  </P>  </P>
282  <P>  <P>
283  The <b>/I</b> modifier requests that <b>pcretest</b> output information about the  The <b>/D</b> modifier is a PCRE debugging feature, and is equivalent to
284  compiled pattern (whether it is anchored, has a fixed first character, and  <b>/BI</b>, that is, both the <b>/B</b> and the <b>/I</b> modifiers.
 so on). It does this by calling <b>pcre_fullinfo()</b> after compiling a  
 pattern. If the pattern is studied, the results of that are also output.  
 </P>  
 <P>  
 The <b>/D</b> modifier is a PCRE debugging feature, which also assumes <b>/I</b>.  
 It causes the internal form of compiled regular expressions to be output after  
 compilation. If the pattern was studied, the information returned is also  
 output.  
285  </P>  </P>
286  <P>  <P>
287  The <b>/F</b> modifier causes <b>pcretest</b> to flip the byte order of the  The <b>/F</b> modifier causes <b>pcretest</b> to flip the byte order of the
# Line 217  available when the POSIX interface to PC Line 293  available when the POSIX interface to PC
293  reloading compiled patterns below.  reloading compiled patterns below.
294  </P>  </P>
295  <P>  <P>
296  The <b>/S</b> modifier causes <b>pcre_study()</b> to be called after the  The <b>/I</b> modifier requests that <b>pcretest</b> output information about the
297  expression has been compiled, and the results used when the expression is  compiled pattern (whether it is anchored, has a fixed first character, and
298  matched.  so on). It does this by calling <b>pcre_fullinfo()</b> after compiling a
299    pattern. If the pattern is studied, the results of that are also output.
300    </P>
301    <P>
302    The <b>/K</b> modifier requests <b>pcretest</b> to show names from backtracking
303    control verbs that are returned from calls to <b>pcre_exec()</b>. It causes
304    <b>pcretest</b> to create a <b>pcre_extra</b> block if one has not already been
305    created by a call to <b>pcre_study()</b>, and to set the PCRE_EXTRA_MARK flag
306    and the <b>mark</b> field within it, every time that <b>pcre_exec()</b> is
307    called. If the variable that the <b>mark</b> field points to is non-NULL for a
308    match, non-match, or partial match, <b>pcretest</b> prints the string to which
309    it points. For a match, this is shown on a line by itself, tagged with "MK:".
310    For a non-match it is added to the message.
311    </P>
312    <P>
313    The <b>/L</b> modifier must be followed directly by the name of a locale, for
314    example,
315    <pre>
316      /pattern/Lfr_FR
317    </pre>
318    For this reason, it must be the last modifier. The given locale is set,
319    <b>pcre_maketables()</b> is called to build a set of character tables for the
320    locale, and this is then passed to <b>pcre_compile()</b> when compiling the
321    regular expression. Without an <b>/L</b> (or <b>/T</b>) modifier, NULL is passed
322    as the tables pointer; that is, <b>/L</b> applies only to the expression on
323    which it appears.
324  </P>  </P>
325  <P>  <P>
326  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
327  pattern to be output.  pattern to be output.
328  </P>  </P>
329  <P>  <P>
330    The <b>/S</b> modifier causes <b>pcre_study()</b> to be called after the
331    expression has been compiled, and the results used when the expression is
332    matched.
333    </P>
334    <P>
335    The <b>/T</b> modifier must be followed by a single digit. It causes a specific
336    set of built-in character tables to be passed to <b>pcre_compile()</b>. It is
337    used in the standard PCRE tests to check behaviour with different character
338    tables. The digit specifies the tables as follows:
339    <pre>
340      0   the default ASCII tables, as distributed in
341            pcre_chartables.c.dist
342      1   a set of tables defining ISO 8859 characters
343    </pre>
344    In table 1, some characters whose codes are greater than 128 are identified as
345    letters, digits, spaces, etc.
346    </P>
347    <br><b>
348    Using the POSIX wrapper API
349    </b><br>
350    <P>
351  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
352  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
353  <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:
354  present, and REG_NEWLINE is set if <b>/m</b> is present. The wrapper functions  <pre>
355  force PCRE_DOLLAR_ENDONLY always, and PCRE_DOTALL unless REG_NEWLINE is set.    /i    REG_ICASE
356  </P>    /m    REG_NEWLINE
357  <P>    /N    REG_NOSUB
358  The <b>/8</b> modifier causes <b>pcretest</b> to call PCRE with the PCRE_UTF8    /s    REG_DOTALL     )
359  option set. This turns on support for UTF-8 character handling in PCRE,    /U    REG_UNGREEDY   ) These options are not part of
360  provided that it was compiled with this support enabled. This modifier also    /W    REG_UCP        )   the POSIX standard
361  causes any non-printing characters in output strings to be printed using the    /8    REG_UTF8       )
362  \x{hh...} notation if they are valid UTF-8 sequences.  </pre>
363  </P>  The <b>/+</b> modifier works as described above. All other modifiers are
364  <P>  ignored.
 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.  
365  </P>  </P>
366  <br><a name="SEC5" href="#TOC1">DATA LINES</a><br>  <br><a name="SEC5" href="#TOC1">DATA LINES</a><br>
367  <P>  <P>
# Line 253  complicated features of PCRE. If you are Line 372  complicated features of PCRE. If you are
372  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
373  recognized:  recognized:
374  <pre>  <pre>
375    \a         alarm (= BEL)    \a         alarm (BEL, \x07)
376    \b         backspace    \b         backspace (\x08)
377    \e         escape    \e         escape (\x27)
378    \f         formfeed    \f         formfeed (\x0c)
379    \n         newline    \n         newline (\x0a)
380    \r         carriage return    \qdd       set the PCRE_MATCH_LIMIT limit to dd (any number of digits)
381    \t         tab    \r         carriage return (\x0d)
382    \v         vertical tab    \t         tab (\x09)
383      \v         vertical tab (\x0b)
384    \nnn       octal character (up to 3 octal digits)    \nnn       octal character (up to 3 octal digits)
385    \xhh       hexadecimal character (up to 2 hex digits)    \xhh       hexadecimal character (up to 2 hex digits)
386    \x{hh...}  hexadecimal character, any number of digits in UTF-8 mode    \x{hh...}  hexadecimal character, any number of digits in UTF-8 mode
387    \A         pass the PCRE_ANCHORED option to <b>pcre_exec()</b>    \A         pass the PCRE_ANCHORED option to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>
388    \B         pass the PCRE_NOTBOL option to <b>pcre_exec()</b>    \B         pass the PCRE_NOTBOL option to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>
389    \Cdd       call pcre_copy_substring() for substring dd after a successful match (number less than 32)    \Cdd       call pcre_copy_substring() for substring dd after a successful match (number less than 32)
390    \Cname     call pcre_copy_named_substring() for substring "name" after a successful match (name termin-    \Cname     call pcre_copy_named_substring() for substring "name" after a successful match (name termin-
391                 ated by next non alphanumeric character)                 ated by next non alphanumeric character)
# Line 274  recognized: Line 394  recognized:
394    \C!n       return 1 instead of 0 when callout number n is reached    \C!n       return 1 instead of 0 when callout number n is reached
395    \C!n!m     return 1 instead of 0 when callout number n is reached for the nth time    \C!n!m     return 1 instead of 0 when callout number n is reached for the nth time
396    \C*n       pass the number n (may be negative) as callout data; this is used as the callout return value    \C*n       pass the number n (may be negative) as callout data; this is used as the callout return value
397      \D         use the <b>pcre_dfa_exec()</b> match function
398      \F         only shortest match for <b>pcre_dfa_exec()</b>
399    \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)
400    \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-
401                 ated by next non-alphanumeric character)                 ated by next non-alphanumeric character)
402    \L         call pcre_get_substringlist() after a successful match    \L         call pcre_get_substringlist() after a successful match
403    \M         discover the minimum MATCH_LIMIT setting    \M         discover the minimum MATCH_LIMIT and MATCH_LIMIT_RECURSION settings
404    \N         pass the PCRE_NOTEMPTY option to <b>pcre_exec()</b>    \N         pass the PCRE_NOTEMPTY option to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>; if used twice, pass the
405                   PCRE_NOTEMPTY_ATSTART option
406    \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)
407    \P         pass the PCRE_PARTIAL option to <b>pcre_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
408                   PCRE_PARTIAL_HARD option
409      \Qdd       set the PCRE_MATCH_LIMIT_RECURSION limit to dd (any number of digits)
410      \R         pass the PCRE_DFA_RESTART option to <b>pcre_dfa_exec()</b>
411    \S         output details of memory get/free calls during matching    \S         output details of memory get/free calls during matching
412    \Z         pass the PCRE_NOTEOL option to <b>pcre_exec()</b>    \Y         pass the PCRE_NO_START_OPTIMIZE option to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>
413    \?         pass the PCRE_NO_UTF8_CHECK option to <b>pcre_exec()</b>    \Z         pass the PCRE_NOTEOL option to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>
414      \?         pass the PCRE_NO_UTF8_CHECK option to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>
415    \&#62;dd       start the match at offset dd (any number of digits);    \&#62;dd       start the match at offset dd (any number of digits);
416                 this sets the <i>startoffset</i> argument for <b>pcre_exec()</b>                 this sets the <i>startoffset</i> argument for <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>
417  </pre>    \&#60;cr&#62;      pass the PCRE_NEWLINE_CR option to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>
418  A backslash followed by anything else just escapes the anything else. If the    \&#60;lf&#62;      pass the PCRE_NEWLINE_LF option to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>
419  very last character is a backslash, it is ignored. This gives a way of passing    \&#60;crlf&#62;    pass the PCRE_NEWLINE_CRLF option to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>
420  an empty line as data, since a real empty line terminates the data input.    \&#60;anycrlf&#62; pass the PCRE_NEWLINE_ANYCRLF option to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>
421      \&#60;any&#62;     pass the PCRE_NEWLINE_ANY option to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>
422    </pre>
423    The escapes that specify line ending sequences are literal strings, exactly as
424    shown. No more than one newline setting should be present in any data line.
425    </P>
426    <P>
427    A backslash followed by anything else just escapes the anything else. If
428    the very last character is a backslash, it is ignored. This gives a way of
429    passing an empty line as data, since a real empty line terminates the data
430    input.
431  </P>  </P>
432  <P>  <P>
433  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
434  different values in the <i>match_limit</i> field of the <b>pcre_extra</b> data  different values in the <i>match_limit</i> and <i>match_limit_recursion</i>
435  structure, until it finds the minimum number that is needed for  fields of the <b>pcre_extra</b> data structure, until it finds the minimum
436  <b>pcre_exec()</b> to complete. This number is a measure of the amount of  numbers for each parameter that allow <b>pcre_exec()</b> to complete. The
437  recursion and backtracking that takes place, and checking it out can be  <i>match_limit</i> number is a measure of the amount of backtracking that takes
438  instructive. For most simple matches, the number is quite small, but for  place, and checking it out can be instructive. For most simple matches, the
439  patterns with very large numbers of matching possibilities, it can become large  number is quite small, but for patterns with very large numbers of matching
440  very quickly with increasing length of subject string.  possibilities, it can become large very quickly with increasing length of
441    subject string. The <i>match_limit_recursion</i> number is a measure of how much
442    stack (or, if PCRE is compiled with NO_RECURSE, how much heap) memory is needed
443    to complete the match attempt.
444  </P>  </P>
445  <P>  <P>
446  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 309  the call of <b>pcre_exec()</b> for the l Line 449  the call of <b>pcre_exec()</b> for the l
449  </P>  </P>
450  <P>  <P>
451  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
452  API to be used, only \B and \Z have any effect, causing REG_NOTBOL and  API to be used, the only option-setting sequences that have any effect are \B,
453  REG_NOTEOL to be passed to <b>regexec()</b> respectively.  \N, and \Z, causing REG_NOTBOL, REG_NOTEMPTY, and REG_NOTEOL, respectively,
454    to be passed to <b>regexec()</b>.
455  </P>  </P>
456  <P>  <P>
457  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
458  of the <b>/8</b> modifier on the pattern. It is recognized always. There may be  of the <b>/8</b> modifier on the pattern. It is recognized always. There may be
459  any number of hexadecimal digits inside the braces. The result is from one to  any number of hexadecimal digits inside the braces. The result is from one to
460  six bytes, encoded according to the UTF-8 rules.  six bytes, encoded according to the original UTF-8 rules of RFC 2279. This
461    allows for values in the range 0 to 0x7FFFFFFF. Note that not all of those are
462    valid Unicode code points, or indeed valid UTF-8 characters according to the
463    later rules in RFC 3629.
464    </P>
465    <br><a name="SEC6" href="#TOC1">THE ALTERNATIVE MATCHING FUNCTION</a><br>
466    <P>
467    By default, <b>pcretest</b> uses the standard PCRE matching function,
468    <b>pcre_exec()</b> to match each data line. From release 6.0, PCRE supports an
469    alternative matching function, <b>pcre_dfa_test()</b>, which operates in a
470    different way, and has some restrictions. The differences between the two
471    functions are described in the
472    <a href="pcrematching.html"><b>pcrematching</b></a>
473    documentation.
474    </P>
475    <P>
476    If a data line contains the \D escape sequence, or if the command line
477    contains the <b>-dfa</b> option, the alternative matching function is called.
478    This function finds all possible matches at a given point. If, however, the \F
479    escape sequence is present in the data line, it stops after the first match is
480    found. This is always the shortest possible match.
481    </P>
482    <br><a name="SEC7" href="#TOC1">DEFAULT OUTPUT FROM PCRETEST</a><br>
483    <P>
484    This section describes the output when the normal matching function,
485    <b>pcre_exec()</b>, is being used.
486  </P>  </P>
 <br><a name="SEC6" href="#TOC1">OUTPUT FROM PCRETEST</a><br>  
487  <P>  <P>
488  When a match succeeds, pcretest outputs the list of captured substrings that  When a match succeeds, pcretest outputs the list of captured substrings that
489  <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
490  the whole pattern. Otherwise, it outputs "No match" or "Partial match"  the whole pattern. Otherwise, it outputs "No match" when the return is
491  when <b>pcre_exec()</b> returns PCRE_ERROR_NOMATCH or PCRE_ERROR_PARTIAL,  PCRE_ERROR_NOMATCH, and "Partial match:" followed by the partially matching
492  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
493  of an interactive pcretest run.  returns, it outputs the PCRE negative error number. Here is an example of an
494    interactive <b>pcretest</b> run.
495  <pre>  <pre>
496    $ pcretest    $ pcretest
497    PCRE version 5.00 07-Sep-2004    PCRE version 7.0 30-Nov-2006
498    
499      re&#62; /^abc(\d+)/      re&#62; /^abc(\d+)/
500    data&#62; abc123    data&#62; abc123
# Line 337  of an interactive pcretest run. Line 503  of an interactive pcretest run.
503    data&#62; xyz    data&#62; xyz
504    No match    No match
505  </pre>  </pre>
506    Note that unset capturing substrings that are not followed by one that is set
507    are not returned by <b>pcre_exec()</b>, and are not shown by <b>pcretest</b>. In
508    the following example, there are two capturing substrings, but when the first
509    data line is matched, the second, unset substring is not shown. An "internal"
510    unset substring is shown as "&#60;unset&#62;", as for the second data line.
511    <pre>
512        re&#62; /(a)|(b)/
513      data&#62; a
514       0: a
515       1: a
516      data&#62; b
517       0: b
518       1: &#60;unset&#62;
519       2: b
520    </pre>
521  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
522  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
523  pattern. If the pattern has the <b>/+</b> modifier, the output for substring 0  pattern. See below for the definition of non-printing characters. If the
524  is followed by the the rest of the subject string, identified by "0+" like  pattern has the <b>/+</b> modifier, the output for substring 0 is followed by
525  this:  the the rest of the subject string, identified by "0+" like this:
526  <pre>  <pre>
527      re&#62; /cat/+      re&#62; /cat/+
528    data&#62; cataract    data&#62; cataract
# Line 371  length (that is, the return from the ext Line 552  length (that is, the return from the ext
552  parentheses after each string for <b>\C</b> and <b>\G</b>.  parentheses after each string for <b>\C</b> and <b>\G</b>.
553  </P>  </P>
554  <P>  <P>
555  Note that while patterns can be continued over several lines (a plain "&#62;"  Note that whereas patterns can be continued over several lines (a plain "&#62;"
556  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
557  included in data by means of the \n escape.  included in data by means of the \n escape (or \r, \r\n, etc., depending on
558    the newline sequence setting).
559  </P>  </P>
560  <br><a name="SEC7" href="#TOC1">CALLOUTS</a><br>  <br><a name="SEC8" href="#TOC1">OUTPUT FROM THE ALTERNATIVE MATCHING FUNCTION</a><br>
561    <P>
562    When the alternative matching function, <b>pcre_dfa_exec()</b>, is used (by
563    means of the \D escape sequence or the <b>-dfa</b> command line option), the
564    output consists of a list of all the matches that start at the first point in
565    the subject where there is at least one match. For example:
566    <pre>
567        re&#62; /(tang|tangerine|tan)/
568      data&#62; yellow tangerine\D
569       0: tangerine
570       1: tang
571       2: tan
572    </pre>
573    (Using the normal matching function on this data finds only "tang".) The
574    longest matching string is always given first (and numbered zero). After a
575    PCRE_ERROR_PARTIAL return, the output is "Partial match:", followed by the
576    partially matching substring.
577    </P>
578    <P>
579    If <b>/g</b> is present on the pattern, the search for further matches resumes
580    at the end of the longest match. For example:
581    <pre>
582        re&#62; /(tang|tangerine|tan)/g
583      data&#62; yellow tangerine and tangy sultana\D
584       0: tangerine
585       1: tang
586       2: tan
587       0: tang
588       1: tan
589       0: tan
590    </pre>
591    Since the matching function does not support substring capture, the escape
592    sequences that are concerned with captured substrings are not relevant.
593    </P>
594    <br><a name="SEC9" href="#TOC1">RESTARTING AFTER A PARTIAL MATCH</a><br>
595    <P>
596    When the alternative matching function has given the PCRE_ERROR_PARTIAL return,
597    indicating that the subject partially matched the pattern, you can restart the
598    match with additional subject data by means of the \R escape sequence. For
599    example:
600    <pre>
601        re&#62; /^\d?\d(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)\d\d$/
602      data&#62; 23ja\P\D
603      Partial match: 23ja
604      data&#62; n05\R\D
605       0: n05
606    </pre>
607    For further information about partial matching, see the
608    <a href="pcrepartial.html"><b>pcrepartial</b></a>
609    documentation.
610    </P>
611    <br><a name="SEC10" href="#TOC1">CALLOUTS</a><br>
612  <P>  <P>
613  If the pattern contains any callout requests, <b>pcretest</b>'s callout function  If the pattern contains any callout requests, <b>pcretest</b>'s callout function
614  is called during matching. By default, it displays the callout number, the  is called during matching. This works with both matching functions. By default,
615  start and current positions in the text at the callout time, and the next  the called function displays the callout number, the start and current
616  pattern item to be tested. For example, the output  positions in the text at the callout time, and the next pattern item to be
617    tested. For example, the output
618  <pre>  <pre>
619    ---&#62;pqrabcdef    ---&#62;pqrabcdef
620      0    ^  ^     \d      0    ^  ^     \d
# Line 406  example: Line 640  example:
640     0: E*     0: E*
641  </pre>  </pre>
642  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
643  default, but you can use an \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
644  change this.  change this.
645  </P>  </P>
646  <P>  <P>
# Line 416  the Line 650  the
650  <a href="pcrecallout.html"><b>pcrecallout</b></a>  <a href="pcrecallout.html"><b>pcrecallout</b></a>
651  documentation.  documentation.
652  </P>  </P>
653  <br><a name="SEC8" href="#TOC1">SAVING AND RELOADING COMPILED PATTERNS</a><br>  <br><a name="SEC11" href="#TOC1">NON-PRINTING CHARACTERS</a><br>
654    <P>
655    When <b>pcretest</b> is outputting text in the compiled version of a pattern,
656    bytes other than 32-126 are always treated as non-printing characters are are
657    therefore shown as hex escapes.
658    </P>
659    <P>
660    When <b>pcretest</b> is outputting text that is a matched part of a subject
661    string, it behaves in the same way, unless a different locale has been set for
662    the pattern (using the <b>/L</b> modifier). In this case, the <b>isprint()</b>
663    function to distinguish printing and non-printing characters.
664    </P>
665    <br><a name="SEC12" href="#TOC1">SAVING AND RELOADING COMPILED PATTERNS</a><br>
666  <P>  <P>
667  The facilities described in this section are not available when the POSIX  The facilities described in this section are not available when the POSIX
668  inteface to PCRE is being used, that is, when the <b>/P</b> pattern modifier is  inteface to PCRE is being used, that is, when the <b>/P</b> pattern modifier is
# Line 478  string using a reloaded pattern is likel Line 724  string using a reloaded pattern is likel
724  Finally, if you attempt to load a file that is not in the correct format, the  Finally, if you attempt to load a file that is not in the correct format, the
725  result is undefined.  result is undefined.
726  </P>  </P>
727  <br><a name="SEC9" href="#TOC1">AUTHOR</a><br>  <br><a name="SEC13" href="#TOC1">SEE ALSO</a><br>
728    <P>
729    <b>pcre</b>(3), <b>pcreapi</b>(3), <b>pcrecallout</b>(3), <b>pcrematching</b>(3),
730    <b>pcrepartial</b>(d), <b>pcrepattern</b>(3), <b>pcreprecompile</b>(3).
731    </P>
732    <br><a name="SEC14" href="#TOC1">AUTHOR</a><br>
733  <P>  <P>
734  Philip Hazel &#60;ph10@cam.ac.uk&#62;  Philip Hazel
735  <br>  <br>
736  University Computing Service,  University Computing Service
737    <br>
738    Cambridge CB2 3QH, England.
739  <br>  <br>
 Cambridge CB2 3QG, England.  
740  </P>  </P>
741    <br><a name="SEC15" href="#TOC1">REVISION</a><br>
742  <P>  <P>
743  Last updated: 10 September 2004  Last updated: 14 June 2010
744    <br>
745    Copyright &copy; 1997-2010 University of Cambridge.
746  <br>  <br>
 Copyright &copy; 1997-2004 University of Cambridge.  
747  <p>  <p>
748  Return to the <a href="index.html">PCRE index page</a>.  Return to the <a href="index.html">PCRE index page</a>.
749  </p>  </p>

Legend:
Removed from v.75  
changed lines
  Added in v.545

  ViewVC Help
Powered by ViewVC 1.1.5