/[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 91 by nigel, Sat Feb 24 21:41:34 2007 UTC revision 512 by ph10, Tue Mar 30 11:11:52 2010 UTC
# Line 23  man page, in case the conversion went wr Line 23  man page, in case the conversion went wr
23  <li><a name="TOC8" href="#SEC8">OUTPUT FROM THE ALTERNATIVE MATCHING FUNCTION</a>  <li><a name="TOC8" href="#SEC8">OUTPUT FROM THE ALTERNATIVE MATCHING FUNCTION</a>
24  <li><a name="TOC9" href="#SEC9">RESTARTING AFTER A PARTIAL MATCH</a>  <li><a name="TOC9" href="#SEC9">RESTARTING AFTER A PARTIAL MATCH</a>
25  <li><a name="TOC10" href="#SEC10">CALLOUTS</a>  <li><a name="TOC10" href="#SEC10">CALLOUTS</a>
26  <li><a name="TOC11" href="#SEC11">SAVING AND RELOADING COMPILED PATTERNS</a>  <li><a name="TOC11" href="#SEC11">NON-PRINTING CHARACTERS</a>
27  <li><a name="TOC12" href="#SEC12">AUTHOR</a>  <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>
# Line 43  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.
# Line 50  about the optional features that are inc Line 58  about the optional features that are inc
58  <P>  <P>
59  <b>-d</b>  <b>-d</b>
60  Behave as if each regex has 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>  </P>
64  <P>  <P>
65  <b>-dfa</b>  <b>-dfa</b>
# Line 59  alternative matching function, <b>pcre_d Line 68  alternative matching function, <b>pcre_d
68  standard <b>pcre_exec()</b> function (more detail is given below).  standard <b>pcre_exec()</b> function (more detail is given below).
69  </P>  </P>
70  <P>  <P>
71    <b>-help</b>
72    Output a brief summary these options and then exit.
73    </P>
74    <P>
75  <b>-i</b>  <b>-i</b>
76  Behave as if each regex has 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 72  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>
# Line 96  megabytes. Line 117  megabytes.
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 107  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.
# Line 114  lines to be matched against the pattern. Line 150  lines to be matched against the pattern.
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  multi-line matches, you have to use the \n escape sequence (or \r or \r\n,  multi-line matches, you have to use the \n escape sequence (or \r or \r\n,
153  depending on the newline setting) in a single line of input to encode the  etc., depending on the newline setting) in a single line of input to encode the
154  newline characters. There is no limit on the length of data lines; the input  newline sequences. There is no limit on the length of data lines; the input
155  buffer is automatically extended if it is too small.  buffer is automatically extended if it is too small.
156  </P>  </P>
157  <P>  <P>
# Line 168  effect as they do in Perl. For example: Line 204  effect as they do in Perl. For example:
204  The following table shows additional modifiers for setting PCRE options that do  The following table shows additional modifiers for setting PCRE options that do
205  not correspond to anything in Perl:  not correspond to anything in Perl:
206  <pre>  <pre>
207    <b>/A</b>       PCRE_ANCHORED    <b>/A</b>              PCRE_ANCHORED
208    <b>/C</b>       PCRE_AUTO_CALLOUT    <b>/C</b>              PCRE_AUTO_CALLOUT
209    <b>/E</b>       PCRE_DOLLAR_ENDONLY    <b>/E</b>              PCRE_DOLLAR_ENDONLY
210    <b>/f</b>       PCRE_FIRSTLINE    <b>/f</b>              PCRE_FIRSTLINE
211    <b>/J</b>       PCRE_DUPNAMES    <b>/J</b>              PCRE_DUPNAMES
212    <b>/N</b>       PCRE_NO_AUTO_CAPTURE    <b>/N</b>              PCRE_NO_AUTO_CAPTURE
213    <b>/U</b>       PCRE_UNGREEDY    <b>/U</b>              PCRE_UNGREEDY
214    <b>/X</b>       PCRE_EXTRA    <b>/X</b>              PCRE_EXTRA
215    <b>/&#60;cr&#62;</b>    PCRE_NEWLINE_CR    <b>/&#60;JS&#62;</b>           PCRE_JAVASCRIPT_COMPAT
216    <b>/&#60;lf&#62;</b>    PCRE_NEWLINE_LF    <b>/&#60;cr&#62;</b>           PCRE_NEWLINE_CR
217    <b>/&#60;crlf&#62;</b>  PCRE_NEWLINE_CRLF    <b>/&#60;lf&#62;</b>           PCRE_NEWLINE_LF
218      <b>/&#60;crlf&#62;</b>         PCRE_NEWLINE_CRLF
219      <b>/&#60;anycrlf&#62;</b>      PCRE_NEWLINE_ANYCRLF
220      <b>/&#60;any&#62;</b>          PCRE_NEWLINE_ANY
221      <b>/&#60;bsr_anycrlf&#62;</b>  PCRE_BSR_ANYCRLF
222      <b>/&#60;bsr_unicode&#62;</b>  PCRE_BSR_UNICODE
223    </pre>
224    Those specifying line ending sequences are literal strings as shown, but the
225    letters can be in either case. This example sets multiline matching with CRLF
226    as the line ending sequence:
227    <pre>
228      /^abc/m&#60;crlf&#62;
229  </pre>  </pre>
230  Those specifying line endings are literal strings as shown. Details of the  Details of the meanings of these PCRE options are given in the
 meanings of these PCRE options are given in the  
231  <a href="pcreapi.html"><b>pcreapi</b></a>  <a href="pcreapi.html"><b>pcreapi</b></a>
232  documentation.  documentation.
233  </P>  </P>
# Line 200  begins with a lookbehind assertion (incl Line 246  begins with a lookbehind assertion (incl
246  </P>  </P>
247  <P>  <P>
248  If any call to <b>pcre_exec()</b> in a <b>/g</b> or <b>/G</b> sequence matches an  If any call to <b>pcre_exec()</b> in a <b>/g</b> or <b>/G</b> sequence matches an
249  empty string, the next call is done with the PCRE_NOTEMPTY and PCRE_ANCHORED  empty string, the next call is done with the PCRE_NOTEMPTY_ATSTART and
250  flags set in order to search for another, non-empty, match at the same point.  PCRE_ANCHORED flags set in order to search for another, non-empty, match at the
251  If this second match fails, the start offset is advanced by one, and the normal  same point. If this second match fails, the start offset is advanced by one
252  match is retried. This imitates the way Perl handles such cases when using the  character, and the normal match is retried. This imitates the way Perl handles
253  <b>/g</b> modifier or the <b>split()</b> function.  such cases when using the <b>/g</b> modifier or the <b>split()</b> function.
254  </P>  </P>
255  <br><b>  <br><b>
256  Other modifiers  Other modifiers
# Line 214  There are yet more modifiers for control Line 260  There are yet more modifiers for control
260  operates.  operates.
261  </P>  </P>
262  <P>  <P>
263    The <b>/8</b> modifier causes <b>pcretest</b> to call PCRE with the PCRE_UTF8
264    option set. This turns on support for UTF-8 character handling in PCRE,
265    provided that it was compiled with this support enabled. This modifier also
266    causes any non-printing characters in output strings to be printed using the
267    \x{hh...} notation if they are valid UTF-8 sequences.
268    </P>
269    <P>
270    If the <b>/?</b> modifier is used with <b>/8</b>, it causes <b>pcretest</b> to
271    call <b>pcre_compile()</b> with the PCRE_NO_UTF8_CHECK option, to suppress the
272    checking of the string for UTF-8 validity.
273    </P>
274    <P>
275  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
276  matched the entire pattern, pcretest should in addition output the remainder of  matched the entire pattern, pcretest should in addition output the remainder of
277  the subject string. This is useful for tests where the subject contains  the subject string. This is useful for tests where the subject contains
278  multiple copies of the same substring.  multiple copies of the same substring.
279  </P>  </P>
280  <P>  <P>
281  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>
282  example,  output a representation of the compiled byte code after compilation. Normally
283  <pre>  this information contains length and offset values; however, if <b>/Z</b> is
284    /pattern/Lfr_FR  also present, this data is replaced by spaces. This is a special feature for
285  </pre>  use in the automatic test scripts; it ensures that the same output is generated
286  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.  
 </P>  
 <P>  
 The <b>/I</b> modifier requests that <b>pcretest</b> output information about the  
 compiled pattern (whether it is anchored, has a fixed first character, and  
 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.  
287  </P>  </P>
288  <P>  <P>
289  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
290  It causes the internal form of compiled regular expressions to be output after  <b>/BI</b>, that is, both the <b>/B</b> and the <b>/I</b> modifiers.
 compilation. If the pattern was studied, the information returned is also  
 output.  
291  </P>  </P>
292  <P>  <P>
293  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  available when the POSIX interface to PC Line 299  available when the POSIX interface to PC
299  reloading compiled patterns below.  reloading compiled patterns below.
300  </P>  </P>
301  <P>  <P>
302  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
303  expression has been compiled, and the results used when the expression is  compiled pattern (whether it is anchored, has a fixed first character, and
304  matched.  so on). It does this by calling <b>pcre_fullinfo()</b> after compiling a
305    pattern. If the pattern is studied, the results of that are also output.
306    </P>
307    <P>
308    The <b>/K</b> modifier requests <b>pcretest</b> to show names from backtracking
309    control verbs that are returned from calls to <b>pcre_exec()</b>. It causes
310    <b>pcretest</b> to create a <b>pcre_extra</b> block if one has not already been
311    created by a call to <b>pcre_study()</b>, and to set the PCRE_EXTRA_MARK flag
312    and the <b>mark</b> field within it, every time that <b>pcre_exec()</b> is
313    called. If the variable that the <b>mark</b> field points to is non-NULL for a
314    match, non-match, or partial match, <b>pcretest</b> prints the string to which
315    it points. For a match, this is shown on a line by itself, tagged with "MK:".
316    For a non-match it is added to the message.
317    </P>
318    <P>
319    The <b>/L</b> modifier must be followed directly by the name of a locale, for
320    example,
321    <pre>
322      /pattern/Lfr_FR
323    </pre>
324    For this reason, it must be the last modifier. The given locale is set,
325    <b>pcre_maketables()</b> is called to build a set of character tables for the
326    locale, and this is then passed to <b>pcre_compile()</b> when compiling the
327    regular expression. Without an <b>/L</b> modifier, NULL is passed as the tables
328    pointer; that is, <b>/L</b> applies only to the expression on which it appears.
329  </P>  </P>
330  <P>  <P>
331  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
# Line 269  present, and REG_NEWLINE is set if <b>/m Line 339  present, and REG_NEWLINE is set if <b>/m
339  force PCRE_DOLLAR_ENDONLY always, and PCRE_DOTALL unless REG_NEWLINE is set.  force PCRE_DOLLAR_ENDONLY always, and PCRE_DOTALL unless REG_NEWLINE is set.
340  </P>  </P>
341  <P>  <P>
342  The <b>/8</b> modifier causes <b>pcretest</b> to call PCRE with the PCRE_UTF8  The <b>/S</b> modifier causes <b>pcre_study()</b> to be called after the
343  option set. This turns on support for UTF-8 character handling in PCRE,  expression has been compiled, and the results used when the expression is
344  provided that it was compiled with this support enabled. This modifier also  matched.
 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.  
345  </P>  </P>
346  <br><a name="SEC5" href="#TOC1">DATA LINES</a><br>  <br><a name="SEC5" href="#TOC1">DATA LINES</a><br>
347  <P>  <P>
# Line 289  complicated features of PCRE. If you are Line 352  complicated features of PCRE. If you are
352  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
353  recognized:  recognized:
354  <pre>  <pre>
355    \a         alarm (= BEL)    \a         alarm (BEL, \x07)
356    \b         backspace    \b         backspace (\x08)
357    \e         escape    \e         escape (\x27)
358    \f         formfeed    \f         formfeed (\x0c)
359    \n         newline    \n         newline (\x0a)
360    \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)
361    \r         carriage return    \r         carriage return (\x0d)
362    \t         tab    \t         tab (\x09)
363    \v         vertical tab    \v         vertical tab (\x0b)
364    \nnn       octal character (up to 3 octal digits)    \nnn       octal character (up to 3 octal digits)
365    \xhh       hexadecimal character (up to 2 hex digits)    \xhh       hexadecimal character (up to 2 hex digits)
366    \x{hh...}  hexadecimal character, any number of digits in UTF-8 mode    \x{hh...}  hexadecimal character, any number of digits in UTF-8 mode
# Line 318  recognized: Line 381  recognized:
381                 ated by next non-alphanumeric character)                 ated by next non-alphanumeric character)
382    \L         call pcre_get_substringlist() after a successful match    \L         call pcre_get_substringlist() after a successful match
383    \M         discover the minimum MATCH_LIMIT and MATCH_LIMIT_RECURSION settings    \M         discover the minimum MATCH_LIMIT and MATCH_LIMIT_RECURSION settings
384    \N         pass the PCRE_NOTEMPTY option to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>    \N         pass the PCRE_NOTEMPTY option to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>; if used twice, pass the
385                   PCRE_NOTEMPTY_ATSTART option
386    \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)
387    \P         pass the PCRE_PARTIAL option to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>    \P         pass the PCRE_PARTIAL_SOFT option to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>; if used twice, pass the
388                   PCRE_PARTIAL_HARD option
389    \Qdd       set the PCRE_MATCH_LIMIT_RECURSION limit to dd (any number of digits)    \Qdd       set the PCRE_MATCH_LIMIT_RECURSION limit to dd (any number of digits)
390    \R         pass the PCRE_DFA_RESTART option to <b>pcre_dfa_exec()</b>    \R         pass the PCRE_DFA_RESTART option to <b>pcre_dfa_exec()</b>
391    \S         output details of memory get/free calls during matching    \S         output details of memory get/free calls during matching
392      \Y         pass the PCRE_NO_START_OPTIMIZE option to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>
393    \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>
394    \?         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>
395    \&#62;dd       start the match at offset dd (any number of digits);    \&#62;dd       start the match at offset dd (any number of digits);
# Line 331  recognized: Line 397  recognized:
397    \&#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>
398    \&#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>
399    \&#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>
400      \&#60;anycrlf&#62; pass the PCRE_NEWLINE_ANYCRLF option to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>
401      \&#60;any&#62;     pass the PCRE_NEWLINE_ANY option to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>
402  </pre>  </pre>
403  The escapes that specify line endings are literal strings, exactly as shown.  The escapes that specify line ending sequences are literal strings, exactly as
404  A backslash followed by anything else just escapes the anything else. If the  shown. No more than one newline setting should be present in any data line.
405  very last character is a backslash, it is ignored. This gives a way of passing  </P>
406  an empty line as data, since a real empty line terminates the data input.  <P>
407    A backslash followed by anything else just escapes the anything else. If
408    the very last character is a backslash, it is ignored. This gives a way of
409    passing an empty line as data, since a real empty line terminates the data
410    input.
411  </P>  </P>
412  <P>  <P>
413  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
# Line 365  and \Z, causing REG_NOTBOL and REG_NOTEO Line 437  and \Z, causing REG_NOTBOL and REG_NOTEO
437  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
438  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
439  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
440  six bytes, encoded according to the UTF-8 rules.  six bytes, encoded according to the original UTF-8 rules of RFC 2279. This
441    allows for values in the range 0 to 0x7FFFFFFF. Note that not all of those are
442    valid Unicode code points, or indeed valid UTF-8 characters according to the
443    later rules in RFC 3629.
444  </P>  </P>
445  <br><a name="SEC6" href="#TOC1">THE ALTERNATIVE MATCHING FUNCTION</a><br>  <br><a name="SEC6" href="#TOC1">THE ALTERNATIVE MATCHING FUNCTION</a><br>
446  <P>  <P>
# Line 392  This section describes the output when t Line 467  This section describes the output when t
467  <P>  <P>
468  When a match succeeds, pcretest outputs the list of captured substrings that  When a match succeeds, pcretest outputs the list of captured substrings that
469  <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
470  the whole pattern. Otherwise, it outputs "No match" or "Partial match"  the whole pattern. Otherwise, it outputs "No match" when the return is
471  when <b>pcre_exec()</b> returns PCRE_ERROR_NOMATCH or PCRE_ERROR_PARTIAL,  PCRE_ERROR_NOMATCH, and "Partial match:" followed by the partially matching
472  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
473  of an interactive <b>pcretest</b> run.  returns, it outputs the PCRE negative error number. Here is an example of an
474    interactive <b>pcretest</b> run.
475  <pre>  <pre>
476    $ pcretest    $ pcretest
477    PCRE version 5.00 07-Sep-2004    PCRE version 7.0 30-Nov-2006
478    
479      re&#62; /^abc(\d+)/      re&#62; /^abc(\d+)/
480    data&#62; abc123    data&#62; abc123
# Line 407  of an interactive <b>pcretest</b> run. Line 483  of an interactive <b>pcretest</b> run.
483    data&#62; xyz    data&#62; xyz
484    No match    No match
485  </pre>  </pre>
486    Note that unset capturing substrings that are not followed by one that is set
487    are not returned by <b>pcre_exec()</b>, and are not shown by <b>pcretest</b>. In
488    the following example, there are two capturing substrings, but when the first
489    data line is matched, the second, unset substring is not shown. An "internal"
490    unset substring is shown as "&#60;unset&#62;", as for the second data line.
491    <pre>
492        re&#62; /(a)|(b)/
493      data&#62; a
494       0: a
495       1: a
496      data&#62; b
497       0: b
498       1: &#60;unset&#62;
499       2: b
500    </pre>
501  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
502  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
503  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
504  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
505  this:  the the rest of the subject string, identified by "0+" like this:
506  <pre>  <pre>
507      re&#62; /cat/+      re&#62; /cat/+
508    data&#62; cataract    data&#62; cataract
# Line 441  length (that is, the return from the ext Line 532  length (that is, the return from the ext
532  parentheses after each string for <b>\C</b> and <b>\G</b>.  parentheses after each string for <b>\C</b> and <b>\G</b>.
533  </P>  </P>
534  <P>  <P>
535  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;"
536  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
537  included in data by means of the \n escape (or \r or \r\n for those newline  included in data by means of the \n escape (or \r, \r\n, etc., depending on
538  settings).  the newline sequence setting).
539  </P>  </P>
540  <br><a name="SEC8" href="#TOC1">OUTPUT FROM THE ALTERNATIVE MATCHING FUNCTION</a><br>  <br><a name="SEC8" href="#TOC1">OUTPUT FROM THE ALTERNATIVE MATCHING FUNCTION</a><br>
541  <P>  <P>
# Line 460  the subject where there is at least one Line 551  the subject where there is at least one
551     2: tan     2: tan
552  </pre>  </pre>
553  (Using the normal matching function on this data finds only "tang".) The  (Using the normal matching function on this data finds only "tang".) The
554  longest matching string is always given first (and numbered zero).  longest matching string is always given first (and numbered zero). After a
555    PCRE_ERROR_PARTIAL return, the output is "Partial match:", followed by the
556    partially matching substring.
557  </P>  </P>
558  <P>  <P>
559  If \fB/g\P 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
560  at the end of the longest match. For example:  at the end of the longest match. For example:
561  <pre>  <pre>
562      re&#62; /(tang|tangerine|tan)/g      re&#62; /(tang|tangerine|tan)/g
# Line 537  the Line 630  the
630  <a href="pcrecallout.html"><b>pcrecallout</b></a>  <a href="pcrecallout.html"><b>pcrecallout</b></a>
631  documentation.  documentation.
632  </P>  </P>
633  <br><a name="SEC11" href="#TOC1">SAVING AND RELOADING COMPILED PATTERNS</a><br>  <br><a name="SEC11" href="#TOC1">NON-PRINTING CHARACTERS</a><br>
634    <P>
635    When <b>pcretest</b> is outputting text in the compiled version of a pattern,
636    bytes other than 32-126 are always treated as non-printing characters are are
637    therefore shown as hex escapes.
638    </P>
639    <P>
640    When <b>pcretest</b> is outputting text that is a matched part of a subject
641    string, it behaves in the same way, unless a different locale has been set for
642    the pattern (using the <b>/L</b> modifier). In this case, the <b>isprint()</b>
643    function to distinguish printing and non-printing characters.
644    </P>
645    <br><a name="SEC12" href="#TOC1">SAVING AND RELOADING COMPILED PATTERNS</a><br>
646  <P>  <P>
647  The facilities described in this section are not available when the POSIX  The facilities described in this section are not available when the POSIX
648  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 599  string using a reloaded pattern is likel Line 704  string using a reloaded pattern is likel
704  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
705  result is undefined.  result is undefined.
706  </P>  </P>
707  <br><a name="SEC12" href="#TOC1">AUTHOR</a><br>  <br><a name="SEC13" href="#TOC1">SEE ALSO</a><br>
708    <P>
709    <b>pcre</b>(3), <b>pcreapi</b>(3), <b>pcrecallout</b>(3), <b>pcrematching</b>(3),
710    <b>pcrepartial</b>(d), <b>pcrepattern</b>(3), <b>pcreprecompile</b>(3).
711    </P>
712    <br><a name="SEC14" href="#TOC1">AUTHOR</a><br>
713  <P>  <P>
714  Philip Hazel  Philip Hazel
715  <br>  <br>
716  University Computing Service,  University Computing Service
717    <br>
718    Cambridge CB2 3QH, England.
719  <br>  <br>
 Cambridge CB2 3QG, England.  
720  </P>  </P>
721    <br><a name="SEC15" href="#TOC1">REVISION</a><br>
722  <P>  <P>
723  Last updated: 29 June 2006  Last updated: 26 March 2010
724    <br>
725    Copyright &copy; 1997-2010 University of Cambridge.
726  <br>  <br>
 Copyright &copy; 1997-2006 University of Cambridge.  
727  <p>  <p>
728  Return to the <a href="index.html">PCRE index page</a>.  Return to the <a href="index.html">PCRE index page</a>.
729  </p>  </p>

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

  ViewVC Help
Powered by ViewVC 1.1.5