/[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 96 by nigel, Fri Mar 2 13:10:43 2007 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  </ul>  </ul>
31  <br><a name="SEC1" href="#TOC1">SYNOPSIS</a><br>  <br><a name="SEC1" href="#TOC1">SYNOPSIS</a><br>
32  <P>  <P>
33  <b>pcretest [-C] [-d] [-i] [-m] [-o osize] [-p] [-t] [source]</b>  <b>pcretest [options] [source] [destination]</b>
34  <b>[destination]</b>  <br>
35  </P>  <br>
 <P>  
36  <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
37  library itself, but it can also be used for experimenting with regular  library itself, but it can also be used for experimenting with regular
38  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 45  documentation.
45  </P>  </P>
46  <br><a name="SEC2" href="#TOC1">OPTIONS</a><br>  <br><a name="SEC2" href="#TOC1">OPTIONS</a><br>
47  <P>  <P>
48    <b>-b</b>
49    Behave as if each regex has the <b>/B</b> (show bytecode) modifier; the internal
50    form is output after compilation.
51    </P>
52    <P>
53  <b>-C</b>  <b>-C</b>
54  Output the version number of the PCRE library, and all available information  Output the version number of the PCRE library, and all available information
55  about the optional features that are included, and then exit.  about the optional features that are included, and then exit.
56  </P>  </P>
57  <P>  <P>
58  <b>-d</b>  <b>-d</b>
59  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
60  form is output after compilation.  form and information about the compiled pattern is output after compilation;
61    <b>-d</b> is equivalent to <b>-b -i</b>.
62    </P>
63    <P>
64    <b>-dfa</b>
65    Behave as if each data line contains the \D escape sequence; this causes the
66    alternative matching function, <b>pcre_dfa_exec()</b>, to be used instead of the
67    standard <b>pcre_exec()</b> function (more detail is given below).
68    </P>
69    <P>
70    <b>-help</b>
71    Output a brief summary these options and then exit.
72  </P>  </P>
73  <P>  <P>
74  <b>-i</b>  <b>-i</b>
75  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
76  compiled pattern is given after compilation.  compiled pattern is given after compilation.
77  </P>  </P>
78  <P>  <P>
# Line 64  with earlier versions of pcretest, <b>-s Line 84  with earlier versions of pcretest, <b>-s
84  <P>  <P>
85  <b>-o</b> <i>osize</i>  <b>-o</b> <i>osize</i>
86  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
87  <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
88  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
89  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
90    changed for individual matching calls by including \O in the data line (see
91    below).
92  </P>  </P>
93  <P>  <P>
94  <b>-p</b>  <b>-p</b>
95  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
96  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
97    set.
98    </P>
99    <P>
100    <b>-q</b>
101    Do not output the version number of <b>pcretest</b> at the start of execution.
102    </P>
103    <P>
104    <b>-S</b> <i>size</i>
105    On Unix-like systems, set the size of the runtime stack to <i>size</i>
106    megabytes.
107  </P>  </P>
108  <P>  <P>
109  <b>-t</b>  <b>-t</b>
110  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
111  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
112  <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
113  timing will be distorted.  timing will be distorted. You can control the number of iterations that are
114    used for timing by following <b>-t</b> with a number (as a separate item on the
115    command line). For example, "-t 1000" would iterate 1000 times. The default is
116    to iterate 500000 times.
117    </P>
118    <P>
119    <b>-tm</b>
120    This is like <b>-t</b> except that it times only the matching phase, not the
121    compile or study phases.
122  </P>  </P>
123  <br><a name="SEC3" href="#TOC1">DESCRIPTION</a><br>  <br><a name="SEC3" href="#TOC1">DESCRIPTION</a><br>
124  <P>  <P>
# Line 95  lines to be matched against the pattern. Line 135  lines to be matched against the pattern.
135  </P>  </P>
136  <P>  <P>
137  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
138  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,
139  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
140  30,000 characters.  newline sequences. There is no limit on the length of data lines; the input
141    buffer is automatically extended if it is too small.
142  </P>  </P>
143  <P>  <P>
144  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
145  expression is read. The regular expressions are given enclosed in any  expression is read. The regular expressions are given enclosed in any
146  non-alphanumeric delimiters other than backslash, for example  non-alphanumeric delimiters other than backslash, for example:
147  <pre>  <pre>
148    /(a|bc)x+yz/    /(a|bc)x+yz/
149  </pre>  </pre>
# Line 149  effect as they do in Perl. For example: Line 190  effect as they do in Perl. For example:
190  The following table shows additional modifiers for setting PCRE options that do  The following table shows additional modifiers for setting PCRE options that do
191  not correspond to anything in Perl:  not correspond to anything in Perl:
192  <pre>  <pre>
193    <b>/A</b>    PCRE_ANCHORED    <b>/A</b>       PCRE_ANCHORED
194    <b>/C</b>    PCRE_AUTO_CALLOUT    <b>/C</b>       PCRE_AUTO_CALLOUT
195    <b>/E</b>    PCRE_DOLLAR_ENDONLY    <b>/E</b>       PCRE_DOLLAR_ENDONLY
196    <b>/N</b>    PCRE_NO_AUTO_CAPTURE    <b>/f</b>       PCRE_FIRSTLINE
197    <b>/U</b>    PCRE_UNGREEDY    <b>/J</b>       PCRE_DUPNAMES
198    <b>/X</b>    PCRE_EXTRA    <b>/N</b>       PCRE_NO_AUTO_CAPTURE
199      <b>/U</b>       PCRE_UNGREEDY
200      <b>/X</b>       PCRE_EXTRA
201      <b>/&#60;cr&#62;</b>    PCRE_NEWLINE_CR
202      <b>/&#60;lf&#62;</b>    PCRE_NEWLINE_LF
203      <b>/&#60;crlf&#62;</b>  PCRE_NEWLINE_CRLF
204      <b>/&#60;any&#62;</b>   PCRE_NEWLINE_ANY
205  </pre>  </pre>
206    Those specifying line ending sequencess are literal strings as shown. This
207    example sets multiline matching with CRLF as the line ending sequence:
208    <pre>
209      /^abc/m&#60;crlf&#62;
210    </pre>
211    Details of the meanings of these PCRE options are given in the
212    <a href="pcreapi.html"><b>pcreapi</b></a>
213    documentation.
214    </P>
215    <br><b>
216    Finding all matches in a string
217    </b><br>
218    <P>
219  Searching for all possible matches within each subject string can be requested  Searching for all possible matches within each subject string can be requested
220  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
221  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 173  If this second match fails, the start of Line 233  If this second match fails, the start of
233  match is retried. This imitates the way Perl handles such cases when using the  match is retried. This imitates the way Perl handles such cases when using the
234  <b>/g</b> modifier or the <b>split()</b> function.  <b>/g</b> modifier or the <b>split()</b> function.
235  </P>  </P>
236    <br><b>
237    Other modifiers
238    </b><br>
239  <P>  <P>
240  There are yet more modifiers for controlling the way <b>pcretest</b>  There are yet more modifiers for controlling the way <b>pcretest</b>
241  operates.  operates.
# Line 184  the subject string. This is useful for t Line 247  the subject string. This is useful for t
247  multiple copies of the same substring.  multiple copies of the same substring.
248  </P>  </P>
249  <P>  <P>
250    The <b>/B</b> modifier is a debugging feature. It requests that <b>pcretest</b>
251    output a representation of the compiled byte code after compilation.
252    </P>
253    <P>
254  The <b>/L</b> modifier must be followed directly by the name of a locale, for  The <b>/L</b> modifier must be followed directly by the name of a locale, for
255  example,  example,
256  <pre>  <pre>
# Line 202  so on). It does this by calling <b>pcre_ Line 269  so on). It does this by calling <b>pcre_
269  pattern. If the pattern is studied, the results of that are also output.  pattern. If the pattern is studied, the results of that are also output.
270  </P>  </P>
271  <P>  <P>
272  The <b>/D</b> modifier is a PCRE debugging feature, which also assumes <b>/I</b>.  The <b>/D</b> modifier is a PCRE debugging feature, and is equivalent to
273  It causes the internal form of compiled regular expressions to be output after  <b>/BI</b>, that is, both the \fP/B\fP and the <b>/I</b> modifiers.
 compilation. If the pattern was studied, the information returned is also  
 output.  
274  </P>  </P>
275  <P>  <P>
276  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 253  complicated features of PCRE. If you are Line 318  complicated features of PCRE. If you are
318  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
319  recognized:  recognized:
320  <pre>  <pre>
321    \a         alarm (= BEL)    \a         alarm (BEL, \x07)
322    \b         backspace    \b         backspace (\x08)
323    \e         escape    \e         escape (\x27)
324    \f         formfeed    \f         formfeed (\x0c)
325    \n         newline    \n         newline (\x0a)
326    \r         carriage return    \qdd       set the PCRE_MATCH_LIMIT limit to dd (any number of digits)
327    \t         tab    \r         carriage return (\x0d)
328    \v         vertical tab    \t         tab (\x09)
329      \v         vertical tab (\x0b)
330    \nnn       octal character (up to 3 octal digits)    \nnn       octal character (up to 3 octal digits)
331    \xhh       hexadecimal character (up to 2 hex digits)    \xhh       hexadecimal character (up to 2 hex digits)
332    \x{hh...}  hexadecimal character, any number of digits in UTF-8 mode    \x{hh...}  hexadecimal character, any number of digits in UTF-8 mode
333    \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>
334    \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>
335    \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)
336    \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-
337                 ated by next non alphanumeric character)                 ated by next non alphanumeric character)
# Line 274  recognized: Line 340  recognized:
340    \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
341    \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
342    \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
343      \D         use the <b>pcre_dfa_exec()</b> match function
344      \F         only shortest match for <b>pcre_dfa_exec()</b>
345    \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)
346    \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-
347                 ated by next non-alphanumeric character)                 ated by next non-alphanumeric character)
348    \L         call pcre_get_substringlist() after a successful match    \L         call pcre_get_substringlist() after a successful match
349    \M         discover the minimum MATCH_LIMIT setting    \M         discover the minimum MATCH_LIMIT and MATCH_LIMIT_RECURSION settings
350    \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>
351    \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)
352    \P         pass the PCRE_PARTIAL option to <b>pcre_exec()</b>    \P         pass the PCRE_PARTIAL option to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>
353      \Qdd       set the PCRE_MATCH_LIMIT_RECURSION limit to dd (any number of digits)
354      \R         pass the PCRE_DFA_RESTART option to <b>pcre_dfa_exec()</b>
355    \S         output details of memory get/free calls during matching    \S         output details of memory get/free calls during matching
356    \Z         pass the PCRE_NOTEOL option to <b>pcre_exec()</b>    \Z         pass the PCRE_NOTEOL option to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>
357    \?         pass the PCRE_NO_UTF8_CHECK option to <b>pcre_exec()</b>    \?         pass the PCRE_NO_UTF8_CHECK option to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>
358    \&#62;dd       start the match at offset dd (any number of digits);    \&#62;dd       start the match at offset dd (any number of digits);
359                 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>
360  </pre>    \&#60;cr&#62;      pass the PCRE_NEWLINE_CR option to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>
361  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>
362  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>
363  an empty line as data, since a real empty line terminates the data input.    \&#60;any&#62;     pass the PCRE_NEWLINE_ANY option to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>
364    </pre>
365    The escapes that specify line ending sequences are literal strings, exactly as
366    shown. No more than one newline setting should be present in any data line.
367    </P>
368    <P>
369    A backslash followed by anything else just escapes the anything else. If
370    the very last character is a backslash, it is ignored. This gives a way of
371    passing an empty line as data, since a real empty line terminates the data
372    input.
373  </P>  </P>
374  <P>  <P>
375  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
376  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>
377  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
378  <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
379  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
380  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
381  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
382  very quickly with increasing length of subject string.  possibilities, it can become large very quickly with increasing length of
383    subject string. The <i>match_limit_recursion</i> number is a measure of how much
384    stack (or, if PCRE is compiled with NO_RECURSE, how much heap) memory is needed
385    to complete the match attempt.
386  </P>  </P>
387  <P>  <P>
388  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 391  the call of <b>pcre_exec()</b> for the l
391  </P>  </P>
392  <P>  <P>
393  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
394  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
395  REG_NOTEOL to be passed to <b>regexec()</b> respectively.  and \Z, causing REG_NOTBOL and REG_NOTEOL, respectively, to be passed to
396    <b>regexec()</b>.
397  </P>  </P>
398  <P>  <P>
399  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 318  of the <b>/8</b> modifier on the pattern Line 401  of the <b>/8</b> modifier on the pattern
401  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
402  six bytes, encoded according to the UTF-8 rules.  six bytes, encoded according to the UTF-8 rules.
403  </P>  </P>
404  <br><a name="SEC6" href="#TOC1">OUTPUT FROM PCRETEST</a><br>  <br><a name="SEC6" href="#TOC1">THE ALTERNATIVE MATCHING FUNCTION</a><br>
405    <P>
406    By default, <b>pcretest</b> uses the standard PCRE matching function,
407    <b>pcre_exec()</b> to match each data line. From release 6.0, PCRE supports an
408    alternative matching function, <b>pcre_dfa_test()</b>, which operates in a
409    different way, and has some restrictions. The differences between the two
410    functions are described in the
411    <a href="pcrematching.html"><b>pcrematching</b></a>
412    documentation.
413    </P>
414    <P>
415    If a data line contains the \D escape sequence, or if the command line
416    contains the <b>-dfa</b> option, the alternative matching function is called.
417    This function finds all possible matches at a given point. If, however, the \F
418    escape sequence is present in the data line, it stops after the first match is
419    found. This is always the shortest possible match.
420    </P>
421    <br><a name="SEC7" href="#TOC1">DEFAULT OUTPUT FROM PCRETEST</a><br>
422    <P>
423    This section describes the output when the normal matching function,
424    <b>pcre_exec()</b>, is being used.
425    </P>
426  <P>  <P>
427  When a match succeeds, pcretest outputs the list of captured substrings that  When a match succeeds, pcretest outputs the list of captured substrings that
428  <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
429  the whole pattern. Otherwise, it outputs "No match" or "Partial match"  the whole pattern. Otherwise, it outputs "No match" or "Partial match"
430  when <b>pcre_exec()</b> returns PCRE_ERROR_NOMATCH or PCRE_ERROR_PARTIAL,  when <b>pcre_exec()</b> returns PCRE_ERROR_NOMATCH or PCRE_ERROR_PARTIAL,
431  respectively, and otherwise the PCRE negative error number. Here is an example  respectively, and otherwise the PCRE negative error number. Here is an example
432  of an interactive pcretest run.  of an interactive <b>pcretest</b> run.
433  <pre>  <pre>
434    $ pcretest    $ pcretest
435    PCRE version 5.00 07-Sep-2004    PCRE version 7.0 30-Nov-2006
436    
437      re&#62; /^abc(\d+)/      re&#62; /^abc(\d+)/
438    data&#62; abc123    data&#62; abc123
# Line 339  of an interactive pcretest run. Line 443  of an interactive pcretest run.
443  </pre>  </pre>
444  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
445  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
446  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
447  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
448  this:  the the rest of the subject string, identified by "0+" like this:
449  <pre>  <pre>
450      re&#62; /cat/+      re&#62; /cat/+
451    data&#62; cataract    data&#62; cataract
# Line 371  length (that is, the return from the ext Line 475  length (that is, the return from the ext
475  parentheses after each string for <b>\C</b> and <b>\G</b>.  parentheses after each string for <b>\C</b> and <b>\G</b>.
476  </P>  </P>
477  <P>  <P>
478  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;"
479  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
480  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
481    the newline sequence setting).
482  </P>  </P>
483  <br><a name="SEC7" href="#TOC1">CALLOUTS</a><br>  <br><a name="SEC8" href="#TOC1">OUTPUT FROM THE ALTERNATIVE MATCHING FUNCTION</a><br>
484    <P>
485    When the alternative matching function, <b>pcre_dfa_exec()</b>, is used (by
486    means of the \D escape sequence or the <b>-dfa</b> command line option), the
487    output consists of a list of all the matches that start at the first point in
488    the subject where there is at least one match. For example:
489    <pre>
490        re&#62; /(tang|tangerine|tan)/
491      data&#62; yellow tangerine\D
492       0: tangerine
493       1: tang
494       2: tan
495    </pre>
496    (Using the normal matching function on this data finds only "tang".) The
497    longest matching string is always given first (and numbered zero).
498    </P>
499    <P>
500    If <b>/g</b> is present on the pattern, the search for further matches resumes
501    at the end of the longest match. For example:
502    <pre>
503        re&#62; /(tang|tangerine|tan)/g
504      data&#62; yellow tangerine and tangy sultana\D
505       0: tangerine
506       1: tang
507       2: tan
508       0: tang
509       1: tan
510       0: tan
511    </pre>
512    Since the matching function does not support substring capture, the escape
513    sequences that are concerned with captured substrings are not relevant.
514    </P>
515    <br><a name="SEC9" href="#TOC1">RESTARTING AFTER A PARTIAL MATCH</a><br>
516    <P>
517    When the alternative matching function has given the PCRE_ERROR_PARTIAL return,
518    indicating that the subject partially matched the pattern, you can restart the
519    match with additional subject data by means of the \R escape sequence. For
520    example:
521    <pre>
522        re&#62; /^\d?\d(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)\d\d$/
523      data&#62; 23ja\P\D
524      Partial match: 23ja
525      data&#62; n05\R\D
526       0: n05
527    </pre>
528    For further information about partial matching, see the
529    <a href="pcrepartial.html"><b>pcrepartial</b></a>
530    documentation.
531    </P>
532    <br><a name="SEC10" href="#TOC1">CALLOUTS</a><br>
533  <P>  <P>
534  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
535  is called during matching. By default, it displays the callout number, the  is called during matching. This works with both matching functions. By default,
536  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
537  pattern item to be tested. For example, the output  positions in the text at the callout time, and the next pattern item to be
538    tested. For example, the output
539  <pre>  <pre>
540    ---&#62;pqrabcdef    ---&#62;pqrabcdef
541      0    ^  ^     \d      0    ^  ^     \d
# Line 406  example: Line 561  example:
561     0: E*     0: E*
562  </pre>  </pre>
563  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
564  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
565  change this.  change this.
566  </P>  </P>
567  <P>  <P>
# Line 416  the Line 571  the
571  <a href="pcrecallout.html"><b>pcrecallout</b></a>  <a href="pcrecallout.html"><b>pcrecallout</b></a>
572  documentation.  documentation.
573  </P>  </P>
574  <br><a name="SEC8" href="#TOC1">SAVING AND RELOADING COMPILED PATTERNS</a><br>  <br><a name="SEC11" href="#TOC1">NON-PRINTING CHARACTERS</a><br>
575    <P>
576    When <b>pcretest</b> is outputting text in the compiled version of a pattern,
577    bytes other than 32-126 are always treated as non-printing characters are are
578    therefore shown as hex escapes.
579    </P>
580    <P>
581    When <b>pcretest</b> is outputting text that is a matched part of a subject
582    string, it behaves in the same way, unless a different locale has been set for
583    the pattern (using the <b>/L</b> modifier). In this case, the <b>isprint()</b>
584    function to distinguish printing and non-printing characters.
585    </P>
586    <br><a name="SEC12" href="#TOC1">SAVING AND RELOADING COMPILED PATTERNS</a><br>
587  <P>  <P>
588  The facilities described in this section are not available when the POSIX  The facilities described in this section are not available when the POSIX
589  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 645  string using a reloaded pattern is likel
645  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
646  result is undefined.  result is undefined.
647  </P>  </P>
648  <br><a name="SEC9" href="#TOC1">AUTHOR</a><br>  <br><a name="SEC13" href="#TOC1">SEE ALSO</a><br>
649    <P>
650    <b>pcre</b>(3), <b>pcreapi</b>(3), <b>pcrecallout</b>(3), <b>pcrematching</b>(3),
651    <b>pcrepartial</b>(d), \fPpcrepattern\fP(3), <b>pcreprecompile</b>(3).
652    </P>
653    <br><a name="SEC14" href="#TOC1">AUTHOR</a><br>
654  <P>  <P>
655  Philip Hazel &#60;ph10@cam.ac.uk&#62;  Philip Hazel
656  <br>  <br>
657  University Computing Service,  University Computing Service,
658  <br>  <br>
659  Cambridge CB2 3QG, England.  Cambridge CB2 3QH, England.
660  </P>  </P>
661  <P>  <P>
662  Last updated: 10 September 2004  Last updated: 30 November 2006
663  <br>  <br>
664  Copyright &copy; 1997-2004 University of Cambridge.  Copyright &copy; 1997-2006 University of Cambridge.
665  <p>  <p>
666  Return to the <a href="index.html">PCRE index page</a>.  Return to the <a href="index.html">PCRE index page</a>.
667  </p>  </p>

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

  ViewVC Help
Powered by ViewVC 1.1.5