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

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

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

revision 518 by ph10, Tue May 18 15:47:01 2010 UTC revision 598 by ph10, Sat May 7 15:37:31 2011 UTC
# Line 169  The following table shows additional mod Line 169  The following table shows additional mod
169  options that do not correspond to anything in Perl:  options that do not correspond to anything in Perl:
170  .sp  .sp
171    \fB/8\fP              PCRE_UTF8    \fB/8\fP              PCRE_UTF8
172    \fB/?\fP              PCRE_NO_UTF8_CHECK    \fB/?\fP              PCRE_NO_UTF8_CHECK
173    \fB/A\fP              PCRE_ANCHORED    \fB/A\fP              PCRE_ANCHORED
174    \fB/C\fP              PCRE_AUTO_CALLOUT    \fB/C\fP              PCRE_AUTO_CALLOUT
175    \fB/E\fP              PCRE_DOLLAR_ENDONLY    \fB/E\fP              PCRE_DOLLAR_ENDONLY
# Line 177  options that do not correspond to anythi Line 177  options that do not correspond to anythi
177    \fB/J\fP              PCRE_DUPNAMES    \fB/J\fP              PCRE_DUPNAMES
178    \fB/N\fP              PCRE_NO_AUTO_CAPTURE    \fB/N\fP              PCRE_NO_AUTO_CAPTURE
179    \fB/U\fP              PCRE_UNGREEDY    \fB/U\fP              PCRE_UNGREEDY
180    \fB/W\fP              PCRE_UCP    \fB/W\fP              PCRE_UCP
181    \fB/X\fP              PCRE_EXTRA    \fB/X\fP              PCRE_EXTRA
182      \fB/Y\fP              PCRE_NO_START_OPTIMIZE
183    \fB/<JS>\fP           PCRE_JAVASCRIPT_COMPAT    \fB/<JS>\fP           PCRE_JAVASCRIPT_COMPAT
184    \fB/<cr>\fP           PCRE_NEWLINE_CR    \fB/<cr>\fP           PCRE_NEWLINE_CR
185    \fB/<lf>\fP           PCRE_NEWLINE_LF    \fB/<lf>\fP           PCRE_NEWLINE_LF
# Line 201  options are given in the Line 202  options are given in the
202  .\" HREF  .\" HREF
203  \fBpcreapi\fP  \fBpcreapi\fP
204  .\"  .\"
205  documentation.  documentation.
206  .  .
207  .  .
208  .SS "Finding all matches in a string"  .SS "Finding all matches in a string"
# Line 219  begins with a lookbehind assertion (incl Line 220  begins with a lookbehind assertion (incl
220  If any call to \fBpcre_exec()\fP in a \fB/g\fP or \fB/G\fP sequence matches an  If any call to \fBpcre_exec()\fP in a \fB/g\fP or \fB/G\fP sequence matches an
221  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
222  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
223  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
224  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
225  such cases when using the \fB/g\fP modifier or the \fBsplit()\fP function.  using the \fB/g\fP modifier or the \fBsplit()\fP function. Normally, the start
226    offset is advanced by one character, but if the newline convention recognizes
227    CRLF as a newline, and the current character is CR followed by LF, an advance
228    of two is used.
229  .  .
230  .  .
231  .SS "Other modifiers"  .SS "Other modifiers"
# Line 276  example, Line 280  example,
280  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,
281  \fBpcre_maketables()\fP is called to build a set of character tables for the  \fBpcre_maketables()\fP is called to build a set of character tables for the
282  locale, and this is then passed to \fBpcre_compile()\fP when compiling the  locale, and this is then passed to \fBpcre_compile()\fP when compiling the
283  regular expression. Without an \fB/L\fP modifier, NULL is passed as the tables  regular expression. Without an \fB/L\fP (or \fB/T\fP) modifier, NULL is passed
284  pointer; that is, \fB/L\fP applies only to the expression on which it appears.  as the tables pointer; that is, \fB/L\fP applies only to the expression on
285    which it appears.
286  .P  .P
287  The \fB/M\fP modifier causes the size of memory block used to hold the compiled  The \fB/M\fP modifier causes the size of memory block used to hold the compiled
288  pattern to be output.  pattern to be output.
# Line 285  pattern to be output. Line 290  pattern to be output.
290  The \fB/S\fP modifier causes \fBpcre_study()\fP to be called after the  The \fB/S\fP modifier causes \fBpcre_study()\fP to be called after the
291  expression has been compiled, and the results used when the expression is  expression has been compiled, and the results used when the expression is
292  matched.  matched.
293    .P
294    The \fB/T\fP modifier must be followed by a single digit. It causes a specific
295    set of built-in character tables to be passed to \fBpcre_compile()\fP. It is
296    used in the standard PCRE tests to check behaviour with different character
297    tables. The digit specifies the tables as follows:
298    .sp
299      0   the default ASCII tables, as distributed in
300            pcre_chartables.c.dist
301      1   a set of tables defining ISO 8859 characters
302    .sp
303    In table 1, some characters whose codes are greater than 128 are identified as
304    letters, digits, spaces, etc.
305  .  .
306  .  .
307  .SS "Using the POSIX wrapper API"  .SS "Using the POSIX wrapper API"
308  .rs  .rs
309  .sp  .sp
310  The \fB/P\fP modifier causes \fBpcretest\fP to call PCRE via the POSIX wrapper  The \fB/P\fP modifier causes \fBpcretest\fP to call PCRE via the POSIX wrapper
311  API rather than its native API. When \fB/P\fP is set, the following modifiers  API rather than its native API. When \fB/P\fP is set, the following modifiers
312  set options for the \fBregcomp()\fP function:  set options for the \fBregcomp()\fP function:
313  .sp  .sp
314    /i    REG_ICASE    /i    REG_ICASE
315    /m    REG_NEWLINE    /m    REG_NEWLINE
316    /N    REG_NOSUB    /N    REG_NOSUB
317    /s    REG_DOTALL     )    /s    REG_DOTALL     )
318    /U    REG_UNGREEDY   ) These options are not part of    /U    REG_UNGREEDY   ) These options are not part of
319    /W    REG_UCP        )   the POSIX standard    /W    REG_UCP        )   the POSIX standard
320    /8    REG_UTF8       )    /8    REG_UTF8       )
321  .sp  .sp
# Line 328  recognized: Line 345  recognized:
345    \et         tab (\ex09)    \et         tab (\ex09)
346    \ev         vertical tab (\ex0b)    \ev         vertical tab (\ex0b)
347    \ennn       octal character (up to 3 octal digits)    \ennn       octal character (up to 3 octal digits)
348    \exhh       hexadecimal character (up to 2 hex digits)                 always a byte unless > 255 in UTF-8 mode
349      \exhh       hexadecimal byte (up to 2 hex digits)
350  .\" JOIN  .\" JOIN
351    \ex{hh...}  hexadecimal character, any number of digits    \ex{hh...}  hexadecimal character, any number of digits
352                 in UTF-8 mode                 in UTF-8 mode
# Line 398  recognized: Line 416  recognized:
416  .\" JOIN  .\" JOIN
417    \e?         pass the PCRE_NO_UTF8_CHECK option to    \e?         pass the PCRE_NO_UTF8_CHECK option to
418                 \fBpcre_exec()\fP or \fBpcre_dfa_exec()\fP                 \fBpcre_exec()\fP or \fBpcre_dfa_exec()\fP
   \e>dd       start the match at offset dd (any number of digits);  
419  .\" JOIN  .\" JOIN
420                 this sets the \fIstartoffset\fP argument for \fBpcre_exec()\fP    \e>dd       start the match at offset dd (optional "-"; then
421                 or \fBpcre_dfa_exec()\fP                 any number of digits); this sets the \fIstartoffset\fP
422                   argument for \fBpcre_exec()\fP or \fBpcre_dfa_exec()\fP
423  .\" JOIN  .\" JOIN
424    \e<cr>      pass the PCRE_NEWLINE_CR option to \fBpcre_exec()\fP    \e<cr>      pass the PCRE_NEWLINE_CR option to \fBpcre_exec()\fP
425                 or \fBpcre_dfa_exec()\fP                 or \fBpcre_dfa_exec()\fP
# Line 418  recognized: Line 436  recognized:
436    \e<any>     pass the PCRE_NEWLINE_ANY option to \fBpcre_exec()\fP    \e<any>     pass the PCRE_NEWLINE_ANY option to \fBpcre_exec()\fP
437                 or \fBpcre_dfa_exec()\fP                 or \fBpcre_dfa_exec()\fP
438  .sp  .sp
439    Note that \exhh always specifies one byte, even in UTF-8 mode; this makes it
440    possible to construct invalid UTF-8 sequences for testing purposes. On the
441    other hand, \ex{hh} is interpreted as a UTF-8 character in UTF-8 mode,
442    generating more than one byte if the value is greater than 127. When not in
443    UTF-8 mode, it generates one byte for values less than 256, and causes an error
444    for greater values.
445    .P
446  The escapes that specify line ending sequences are literal strings, exactly as  The escapes that specify line ending sequences are literal strings, exactly as
447  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.
448  .P  .P
# Line 482  found. This is always the shortest possi Line 507  found. This is always the shortest possi
507  This section describes the output when the normal matching function,  This section describes the output when the normal matching function,
508  \fBpcre_exec()\fP, is being used.  \fBpcre_exec()\fP, is being used.
509  .P  .P
510  When a match succeeds, pcretest outputs the list of captured substrings that  When a match succeeds, \fBpcretest\fP outputs the list of captured substrings
511  \fBpcre_exec()\fP returns, starting with number 0 for the string that matched  that \fBpcre_exec()\fP returns, starting with number 0 for the string that
512  the whole pattern. Otherwise, it outputs "No match" when the return is  matched the whole pattern. Otherwise, it outputs "No match" when the return is
513  PCRE_ERROR_NOMATCH, and "Partial match:" followed by the partially matching  PCRE_ERROR_NOMATCH, and "Partial match:" followed by the partially matching
514  substring when \fBpcre_exec()\fP returns PCRE_ERROR_PARTIAL. For any other  substring when \fBpcre_exec()\fP returns PCRE_ERROR_PARTIAL. (Note that this is
515  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
516  interactive \fBpcretest\fP run.  include characters before the actual match start if a lookbehind assertion,
517    \eK, \eb, or \eB was involved.) For any other return, \fBpcretest\fP outputs
518    the PCRE negative error number and a short descriptive phrase. If the error is
519    a failed UTF-8 string check, the byte offset of the start of the failing
520    character and the reason code are also output, provided that the size of the
521    output vector is at least two. Here is an example of an interactive
522    \fBpcretest\fP run.
523  .sp  .sp
524    $ pcretest    $ pcretest
525    PCRE version 7.0 30-Nov-2006    PCRE version 8.13 2011-04-30
526  .sp  .sp
527      re> /^abc(\ed+)/      re> /^abc(\ed+)/
528    data> abc123    data> abc123
# Line 500  interactive \fBpcretest\fP run. Line 531  interactive \fBpcretest\fP run.
531    data> xyz    data> xyz
532    No match    No match
533  .sp  .sp
534  Note that unset capturing substrings that are not followed by one that is set  Unset capturing substrings that are not followed by one that is set are not
535  are not returned by \fBpcre_exec()\fP, and are not shown by \fBpcretest\fP. In  returned by \fBpcre_exec()\fP, and are not shown by \fBpcretest\fP. In the
536  the following example, there are two capturing substrings, but when the first  following example, there are two capturing substrings, but when the first data
537  data line is matched, the second, unset substring is not shown. An "internal"  line is matched, the second, unset substring is not shown. An "internal" unset
538  unset substring is shown as "<unset>", as for the second data line.  substring is shown as "<unset>", as for the second data line.
539  .sp  .sp
540      re> /(a)|(b)/      re> /(a)|(b)/
541    data> a    data> a
# Line 538  matching attempts are output in sequence Line 569  matching attempts are output in sequence
569     0: ipp     0: ipp
570     1: pp     1: pp
571  .sp  .sp
572  "No match" is output only if the first match attempt fails.  "No match" is output only if the first match attempt fails. Here is an example
573    of a failure message (the offset 4 that is specified by \e>4 is past the end of
574    the subject string):
575    .sp
576        re> /xyz/
577      data> xyz\>4
578      Error -24 (bad offset value)
579  .P  .P
580  If any of the sequences \fB\eC\fP, \fB\eG\fP, or \fB\eL\fP are present in a  If any of the sequences \fB\eC\fP, \fB\eG\fP, or \fB\eL\fP are present in a
581  data line that is successfully matched, the substrings extracted by the  data line that is successfully matched, the substrings extracted by the
# Line 571  the subject where there is at least one Line 608  the subject where there is at least one
608  (Using the normal matching function on this data finds only "tang".) The  (Using the normal matching function on this data finds only "tang".) The
609  longest matching string is always given first (and numbered zero). After a  longest matching string is always given first (and numbered zero). After a
610  PCRE_ERROR_PARTIAL return, the output is "Partial match:", followed by the  PCRE_ERROR_PARTIAL return, the output is "Partial match:", followed by the
611  partially matching substring.  partially matching substring. (Note that this is the entire substring that was
612    inspected during the partial match; it may include characters before the actual
613    match start if a lookbehind assertion, \eK, \eb, or \eB was involved.)
614  .P  .P
615  If \fB/g\fP is present on the pattern, the search for further matches resumes  If \fB/g\fP is present on the pattern, the search for further matches resumes
616  at the end of the longest match. For example:  at the end of the longest match. For example:
# Line 750  Cambridge CB2 3QH, England. Line 789  Cambridge CB2 3QH, England.
789  .rs  .rs
790  .sp  .sp
791  .nf  .nf
792  Last updated: 16 May 2010  Last updated: 06 May 2011
793  Copyright (c) 1997-2010 University of Cambridge.  Copyright (c) 1997-2011 University of Cambridge.
794  .fi  .fi

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

  ViewVC Help
Powered by ViewVC 1.1.5