/[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 518 by ph10, Tue May 18 15:47:01 2010 UTC revision 579 by ph10, Wed Nov 24 17:39:25 2010 UTC
# Line 201  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>/8</b>              PCRE_UTF8    <b>/8</b>              PCRE_UTF8
208    <b>/?</b>              PCRE_NO_UTF8_CHECK    <b>/?</b>              PCRE_NO_UTF8_CHECK
209    <b>/A</b>              PCRE_ANCHORED    <b>/A</b>              PCRE_ANCHORED
210    <b>/C</b>              PCRE_AUTO_CALLOUT    <b>/C</b>              PCRE_AUTO_CALLOUT
211    <b>/E</b>              PCRE_DOLLAR_ENDONLY    <b>/E</b>              PCRE_DOLLAR_ENDONLY
# Line 213  not correspond to anything in Perl: Line 213  not correspond to anything in Perl:
213    <b>/J</b>              PCRE_DUPNAMES    <b>/J</b>              PCRE_DUPNAMES
214    <b>/N</b>              PCRE_NO_AUTO_CAPTURE    <b>/N</b>              PCRE_NO_AUTO_CAPTURE
215    <b>/U</b>              PCRE_UNGREEDY    <b>/U</b>              PCRE_UNGREEDY
216    <b>/W</b>              PCRE_UCP    <b>/W</b>              PCRE_UCP
217    <b>/X</b>              PCRE_EXTRA    <b>/X</b>              PCRE_EXTRA
218      <b>/Y</b>              PCRE_NO_START_OPTIMIZE
219    <b>/&#60;JS&#62;</b>           PCRE_JAVASCRIPT_COMPAT    <b>/&#60;JS&#62;</b>           PCRE_JAVASCRIPT_COMPAT
220    <b>/&#60;cr&#62;</b>           PCRE_NEWLINE_CR    <b>/&#60;cr&#62;</b>           PCRE_NEWLINE_CR
221    <b>/&#60;lf&#62;</b>           PCRE_NEWLINE_LF    <b>/&#60;lf&#62;</b>           PCRE_NEWLINE_LF
# Line 235  any non-printing characters in output st Line 236  any non-printing characters in output st
236  \x{hh...} notation if they are valid UTF-8 sequences. Full details of the PCRE  \x{hh...} notation if they are valid UTF-8 sequences. Full details of the PCRE
237  options are given in the  options are given in the
238  <a href="pcreapi.html"><b>pcreapi</b></a>  <a href="pcreapi.html"><b>pcreapi</b></a>
239  documentation.  documentation.
240  </P>  </P>
241  <br><b>  <br><b>
242  Finding all matches in a string  Finding all matches in a string
# Line 254  begins with a lookbehind assertion (incl Line 255  begins with a lookbehind assertion (incl
255  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
256  empty string, the next call is done with the PCRE_NOTEMPTY_ATSTART and  empty string, the next call is done with the PCRE_NOTEMPTY_ATSTART and
257  PCRE_ANCHORED flags set in order to search for another, non-empty, match at the  PCRE_ANCHORED flags set in order to search for another, non-empty, match at the
258  same point. If this second match fails, the start offset is advanced by one  same point. If this second match fails, the start offset is advanced, and the
259  character, and the normal match is retried. This imitates the way Perl handles  normal match is retried. This imitates the way Perl handles such cases when
260  such cases when using the <b>/g</b> modifier or the <b>split()</b> function.  using the <b>/g</b> modifier or the <b>split()</b> function. Normally, the start
261    offset is advanced by one character, but if the newline convention recognizes
262    CRLF as a newline, and the current character is CR followed by LF, an advance
263    of two is used.
264  </P>  </P>
265  <br><b>  <br><b>
266  Other modifiers  Other modifiers
# Line 318  example, Line 322  example,
322  For this reason, it must be the last modifier. The given locale is set,  For this reason, it must be the last modifier. The given locale is set,
323  <b>pcre_maketables()</b> is called to build a set of character tables for the  <b>pcre_maketables()</b> is called to build a set of character tables for the
324  locale, and this is then passed to <b>pcre_compile()</b> when compiling the  locale, and this is then passed to <b>pcre_compile()</b> when compiling the
325  regular expression. Without an <b>/L</b> modifier, NULL is passed as the tables  regular expression. Without an <b>/L</b> (or <b>/T</b>) modifier, NULL is passed
326  pointer; that is, <b>/L</b> applies only to the expression on which it appears.  as the tables pointer; that is, <b>/L</b> applies only to the expression on
327    which it appears.
328  </P>  </P>
329  <P>  <P>
330  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
331  pattern to be output.  pattern to be output.
332  </P>  </P>
333  <P>  <P>
 The <b>/P</b> modifier causes <b>pcretest</b> to call PCRE via the POSIX wrapper  
 API rather than its native API. When this is done, all other modifiers except  
 <b>/i</b>, <b>/m</b>, and <b>/+</b> are ignored. REG_ICASE is set if <b>/i</b> is  
 present, and REG_NEWLINE is set if <b>/m</b> is present. The wrapper functions  
 force PCRE_DOLLAR_ENDONLY always, and PCRE_DOTALL unless REG_NEWLINE is set.  
 </P>  
 <P>  
334  The <b>/S</b> modifier causes <b>pcre_study()</b> to be called after the  The <b>/S</b> modifier causes <b>pcre_study()</b> to be called after the
335  expression has been compiled, and the results used when the expression is  expression has been compiled, and the results used when the expression is
336  matched.  matched.
337  </P>  </P>
338    <P>
339    The <b>/T</b> modifier must be followed by a single digit. It causes a specific
340    set of built-in character tables to be passed to <b>pcre_compile()</b>. It is
341    used in the standard PCRE tests to check behaviour with different character
342    tables. The digit specifies the tables as follows:
343    <pre>
344      0   the default ASCII tables, as distributed in
345            pcre_chartables.c.dist
346      1   a set of tables defining ISO 8859 characters
347    </pre>
348    In table 1, some characters whose codes are greater than 128 are identified as
349    letters, digits, spaces, etc.
350    </P>
351    <br><b>
352    Using the POSIX wrapper API
353    </b><br>
354    <P>
355    The <b>/P</b> modifier causes <b>pcretest</b> to call PCRE via the POSIX wrapper
356    API rather than its native API. When <b>/P</b> is set, the following modifiers
357    set options for the <b>regcomp()</b> function:
358    <pre>
359      /i    REG_ICASE
360      /m    REG_NEWLINE
361      /N    REG_NOSUB
362      /s    REG_DOTALL     )
363      /U    REG_UNGREEDY   ) These options are not part of
364      /W    REG_UCP        )   the POSIX standard
365      /8    REG_UTF8       )
366    </pre>
367    The <b>/+</b> modifier works as described above. All other modifiers are
368    ignored.
369    </P>
370  <br><a name="SEC5" href="#TOC1">DATA LINES</a><br>  <br><a name="SEC5" href="#TOC1">DATA LINES</a><br>
371  <P>  <P>
372  Before each data line is passed to <b>pcre_exec()</b>, leading and trailing  Before each data line is passed to <b>pcre_exec()</b>, leading and trailing
# Line 356  recognized: Line 386  recognized:
386    \t         tab (\x09)    \t         tab (\x09)
387    \v         vertical tab (\x0b)    \v         vertical tab (\x0b)
388    \nnn       octal character (up to 3 octal digits)    \nnn       octal character (up to 3 octal digits)
389    \xhh       hexadecimal character (up to 2 hex digits)                 always a byte unless &#62; 255 in UTF-8 mode
390      \xhh       hexadecimal byte (up to 2 hex digits)
391    \x{hh...}  hexadecimal character, any number of digits in UTF-8 mode    \x{hh...}  hexadecimal character, any number of digits in UTF-8 mode
392    \A         pass the PCRE_ANCHORED option to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>    \A         pass the PCRE_ANCHORED option to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>
393    \B         pass the PCRE_NOTBOL option to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>    \B         pass the PCRE_NOTBOL option to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>
# Line 386  recognized: Line 417  recognized:
417    \Y         pass the PCRE_NO_START_OPTIMIZE option to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>    \Y         pass the PCRE_NO_START_OPTIMIZE option to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>
418    \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>
419    \?         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>
420    \&#62;dd       start the match at offset dd (any number of digits);    \&#62;dd       start the match at offset dd (optional "-"; then any number of digits); this sets the <i>startoffset</i>
421                 this sets the <i>startoffset</i> argument for <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>                 argument for <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>
422    \&#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>
423    \&#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>
424    \&#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>
425    \&#60;anycrlf&#62; pass the PCRE_NEWLINE_ANYCRLF option to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>    \&#60;anycrlf&#62; pass the PCRE_NEWLINE_ANYCRLF option to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>
426    \&#60;any&#62;     pass the PCRE_NEWLINE_ANY option to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>    \&#60;any&#62;     pass the PCRE_NEWLINE_ANY option to <b>pcre_exec()</b> or <b>pcre_dfa_exec()</b>
427  </pre>  </pre>
428    Note that \xhh always specifies one byte, even in UTF-8 mode; this makes it
429    possible to construct invalid UTF-8 sequences for testing purposes. On the
430    other hand, \x{hh} is interpreted as a UTF-8 character in UTF-8 mode,
431    generating more than one byte if the value is greater than 127. When not in
432    UTF-8 mode, it generates one byte for values less than 256, and causes an error
433    for greater values.
434    </P>
435    <P>
436  The escapes that specify line ending sequences are literal strings, exactly as  The escapes that specify line ending sequences are literal strings, exactly as
437  shown. No more than one newline setting should be present in any data line.  shown. No more than one newline setting should be present in any data line.
438  </P>  </P>
# Line 423  the call of <b>pcre_exec()</b> for the l Line 462  the call of <b>pcre_exec()</b> for the l
462  </P>  </P>
463  <P>  <P>
464  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
465  API to be used, the only option-setting sequences that have any effect are \B  API to be used, the only option-setting sequences that have any effect are \B,
466  and \Z, causing REG_NOTBOL and REG_NOTEOL, respectively, to be passed to  \N, and \Z, causing REG_NOTBOL, REG_NOTEMPTY, and REG_NOTEOL, respectively,
467  <b>regexec()</b>.  to be passed to <b>regexec()</b>.
468  </P>  </P>
469  <P>  <P>
470  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 463  When a match succeeds, pcretest outputs Line 502  When a match succeeds, pcretest outputs
502  <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
503  the whole pattern. Otherwise, it outputs "No match" when the return is  the whole pattern. Otherwise, it outputs "No match" when the return is
504  PCRE_ERROR_NOMATCH, and "Partial match:" followed by the partially matching  PCRE_ERROR_NOMATCH, and "Partial match:" followed by the partially matching
505  substring when <b>pcre_exec()</b> returns PCRE_ERROR_PARTIAL. For any other  substring when <b>pcre_exec()</b> returns PCRE_ERROR_PARTIAL. (Note that this is
506  returns, it outputs the PCRE negative error number. Here is an example of an  the entire substring that was inspected during the partial match; it may
507  interactive <b>pcretest</b> run.  include characters before the actual match start if a lookbehind assertion,
508    \K, \b, or \B was involved.) For any other returns, it outputs the PCRE
509    negative error number. Here is an example of an interactive <b>pcretest</b> run.
510  <pre>  <pre>
511    $ pcretest    $ pcretest
512    PCRE version 7.0 30-Nov-2006    PCRE version 7.0 30-Nov-2006
# Line 547  the subject where there is at least one Line 588  the subject where there is at least one
588  (Using the normal matching function on this data finds only "tang".) The  (Using the normal matching function on this data finds only "tang".) The
589  longest matching string is always given first (and numbered zero). After a  longest matching string is always given first (and numbered zero). After a
590  PCRE_ERROR_PARTIAL return, the output is "Partial match:", followed by the  PCRE_ERROR_PARTIAL return, the output is "Partial match:", followed by the
591  partially matching substring.  partially matching substring. (Note that this is the entire substring that was
592    inspected during the partial match; it may include characters before the actual
593    match start if a lookbehind assertion, \K, \b, or \B was involved.)
594  </P>  </P>
595  <P>  <P>
596  If <b>/g</b> is present on the pattern, the search for further matches resumes  If <b>/g</b> is present on the pattern, the search for further matches resumes
# Line 714  Cambridge CB2 3QH, England. Line 757  Cambridge CB2 3QH, England.
757  </P>  </P>
758  <br><a name="SEC15" href="#TOC1">REVISION</a><br>  <br><a name="SEC15" href="#TOC1">REVISION</a><br>
759  <P>  <P>
760  Last updated: 12 May 2010  Last updated: 21 November 2010
761  <br>  <br>
762  Copyright &copy; 1997-2010 University of Cambridge.  Copyright &copy; 1997-2010 University of Cambridge.
763  <br>  <br>

Legend:
Removed from v.518  
changed lines
  Added in v.579

  ViewVC Help
Powered by ViewVC 1.1.5