/[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 510 by ph10, Sat Mar 27 17:45:29 2010 UTC revision 566 by ph10, Wed Nov 3 18:32:55 2010 UTC
# Line 165  effect as they do in Perl. For example: Line 165  effect as they do in Perl. For example:
165  .sp  .sp
166    /caseless/i    /caseless/i
167  .sp  .sp
168  The following table shows additional modifiers for setting PCRE options that do  The following table shows additional modifiers for setting PCRE compile-time
169  not correspond to anything in Perl:  options that do not correspond to anything in Perl:
170  .sp  .sp
171      \fB/8\fP              PCRE_UTF8
172      \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 175  not correspond to anything in Perl: Line 177  not correspond to anything in Perl:
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
181    \fB/X\fP              PCRE_EXTRA    \fB/X\fP              PCRE_EXTRA
182    \fB/<JS>\fP           PCRE_JAVASCRIPT_COMPAT    \fB/<JS>\fP           PCRE_JAVASCRIPT_COMPAT
183    \fB/<cr>\fP           PCRE_NEWLINE_CR    \fB/<cr>\fP           PCRE_NEWLINE_CR
# Line 185  not correspond to anything in Perl: Line 188  not correspond to anything in Perl:
188    \fB/<bsr_anycrlf>\fP  PCRE_BSR_ANYCRLF    \fB/<bsr_anycrlf>\fP  PCRE_BSR_ANYCRLF
189    \fB/<bsr_unicode>\fP  PCRE_BSR_UNICODE    \fB/<bsr_unicode>\fP  PCRE_BSR_UNICODE
190  .sp  .sp
191  Those specifying line ending sequences are literal strings as shown, but the  The modifiers that are enclosed in angle brackets are literal strings as shown,
192  letters can be in either case. This example sets multiline matching with CRLF  including the angle brackets, but the letters can be in either case. This
193  as the line ending sequence:  example sets multiline matching with CRLF as the line ending sequence:
194  .sp  .sp
195    /^abc/m<crlf>    /^abc/m<crlf>
196  .sp  .sp
197  Details of the meanings of these PCRE options are given in the  As well as turning on the PCRE_UTF8 option, the \fB/8\fP modifier also causes
198    any non-printing characters in output strings to be printed using the
199    \ex{hh...} notation if they are valid UTF-8 sequences. Full details of the PCRE
200    options are given in the
201  .\" HREF  .\" HREF
202  \fBpcreapi\fP  \fBpcreapi\fP
203  .\"  .\"
# Line 213  begins with a lookbehind assertion (incl Line 219  begins with a lookbehind assertion (incl
219  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
220  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
221  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
222  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
223  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
224  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
225    offset is advanced by one character, but if the newline convention recognizes
226    CRLF as a newline, and the current character is CR followed by LF, an advance
227    of two is used.
228  .  .
229  .  .
230  .SS "Other modifiers"  .SS "Other modifiers"
# Line 224  such cases when using the \fB/g\fP modif Line 233  such cases when using the \fB/g\fP modif
233  There are yet more modifiers for controlling the way \fBpcretest\fP  There are yet more modifiers for controlling the way \fBpcretest\fP
234  operates.  operates.
235  .P  .P
 The \fB/8\fP modifier causes \fBpcretest\fP to call PCRE with the PCRE_UTF8  
 option set. This turns on support for UTF-8 character handling in PCRE,  
 provided that it was compiled with this support enabled. This modifier also  
 causes any non-printing characters in output strings to be printed using the  
 \ex{hh...} notation if they are valid UTF-8 sequences.  
 .P  
 If the \fB/?\fP modifier is used with \fB/8\fP, it causes \fBpcretest\fP to  
 call \fBpcre_compile()\fP with the PCRE_NO_UTF8_CHECK option, to suppress the  
 checking of the string for UTF-8 validity.  
 .P  
236  The \fB/+\fP modifier requests that as well as outputting the substring that  The \fB/+\fP modifier requests that as well as outputting the substring that
237  matched the entire pattern, pcretest should in addition output the remainder of  matched the entire pattern, pcretest should in addition output the remainder of
238  the subject string. This is useful for tests where the subject contains  the subject string. This is useful for tests where the subject contains
# Line 268  control verbs that are returned from cal Line 267  control verbs that are returned from cal
267  created by a call to \fBpcre_study()\fP, and to set the PCRE_EXTRA_MARK flag  created by a call to \fBpcre_study()\fP, and to set the PCRE_EXTRA_MARK flag
268  and the \fBmark\fP field within it, every time that \fBpcre_exec()\fP is  and the \fBmark\fP field within it, every time that \fBpcre_exec()\fP is
269  called. If the variable that the \fBmark\fP field points to is non-NULL for a  called. If the variable that the \fBmark\fP field points to is non-NULL for a
270  match, non-match, or partial match, \fBpcretest\fP prints the string to which  match, non-match, or partial match, \fBpcretest\fP prints the string to which
271  it points. For a match, this is shown on a line by itself, tagged with "MK:".  it points. For a match, this is shown on a line by itself, tagged with "MK:".
272  For a non-match it is added to the message.  For a non-match it is added to the message.
273  .P  .P
274  The \fB/L\fP modifier must be followed directly by the name of a locale, for  The \fB/L\fP modifier must be followed directly by the name of a locale, for
# Line 280  example, Line 279  example,
279  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,
280  \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
281  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
282  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
283  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
284    which it appears.
285  .P  .P
286  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
287  pattern to be output.  pattern to be output.
288  .P  .P
 The \fB/P\fP modifier causes \fBpcretest\fP to call PCRE via the POSIX wrapper  
 API rather than its native API. When this is done, all other modifiers except  
 \fB/i\fP, \fB/m\fP, and \fB/+\fP are ignored. REG_ICASE is set if \fB/i\fP is  
 present, and REG_NEWLINE is set if \fB/m\fP is present. The wrapper functions  
 force PCRE_DOLLAR_ENDONLY always, and PCRE_DOTALL unless REG_NEWLINE is set.  
 .P  
289  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
290  expression has been compiled, and the results used when the expression is  expression has been compiled, and the results used when the expression is
291  matched.  matched.
292    .P
293    The \fB/T\fP modifier must be followed by a single digit. It causes a specific
294    set of built-in character tables to be passed to \fBpcre_compile()\fP. It is
295    used in the standard PCRE tests to check behaviour with different character
296    tables. The digit specifies the tables as follows:
297    .sp
298      0   the default ASCII tables, as distributed in
299            pcre_chartables.c.dist
300      1   a set of tables defining ISO 8859 characters
301    .sp
302    In table 1, some characters whose codes are greater than 128 are identified as
303    letters, digits, spaces, etc.
304    .
305    .
306    .SS "Using the POSIX wrapper API"
307    .rs
308    .sp
309    The \fB/P\fP modifier causes \fBpcretest\fP to call PCRE via the POSIX wrapper
310    API rather than its native API. When \fB/P\fP is set, the following modifiers
311    set options for the \fBregcomp()\fP function:
312    .sp
313      /i    REG_ICASE
314      /m    REG_NEWLINE
315      /N    REG_NOSUB
316      /s    REG_DOTALL     )
317      /U    REG_UNGREEDY   ) These options are not part of
318      /W    REG_UCP        )   the POSIX standard
319      /8    REG_UTF8       )
320    .sp
321    The \fB/+\fP modifier works as described above. All other modifiers are
322    ignored.
323  .  .
324  .  .
325  .SH "DATA LINES"  .SH "DATA LINES"
# Line 434  by the \fB-O\fP command line option (or Line 459  by the \fB-O\fP command line option (or
459  the call of \fBpcre_exec()\fP for the line in which it appears.  the call of \fBpcre_exec()\fP for the line in which it appears.
460  .P  .P
461  If the \fB/P\fP modifier was present on the pattern, causing the POSIX wrapper  If the \fB/P\fP modifier was present on the pattern, causing the POSIX wrapper
462  API to be used, the only option-setting sequences that have any effect are \eB  API to be used, the only option-setting sequences that have any effect are \eB,
463  and \eZ, causing REG_NOTBOL and REG_NOTEOL, respectively, to be passed to  \eN, and \eZ, causing REG_NOTBOL, REG_NOTEMPTY, and REG_NOTEOL, respectively,
464  \fBregexec()\fP.  to be passed to \fBregexec()\fP.
465  .P  .P
466  The use of \ex{hh...} to represent UTF-8 characters is not dependent on the use  The use of \ex{hh...} to represent UTF-8 characters is not dependent on the use
467  of the \fB/8\fP modifier on the pattern. It is recognized always. There may be  of the \fB/8\fP modifier on the pattern. It is recognized always. There may be
# Line 477  When a match succeeds, pcretest outputs Line 502  When a match succeeds, pcretest outputs
502  \fBpcre_exec()\fP returns, starting with number 0 for the string that matched  \fBpcre_exec()\fP 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 \fBpcre_exec()\fP returns PCRE_ERROR_PARTIAL. For any other  substring when \fBpcre_exec()\fP 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 \fBpcretest\fP run.  include characters before the actual match start if a lookbehind assertion,
508    \eK, \eb, or \eB was involved.) For any other returns, it outputs the PCRE
509    negative error number. Here is an example of an interactive \fBpcretest\fP run.
510  .sp  .sp
511    $ pcretest    $ pcretest
512    PCRE version 7.0 30-Nov-2006    PCRE version 7.0 30-Nov-2006
# Line 562  the subject where there is at least one Line 589  the subject where there is at least one
589  (Using the normal matching function on this data finds only "tang".) The  (Using the normal matching function on this data finds only "tang".) The
590  longest matching string is always given first (and numbered zero). After a  longest matching string is always given first (and numbered zero). After a
591  PCRE_ERROR_PARTIAL return, the output is "Partial match:", followed by the  PCRE_ERROR_PARTIAL return, the output is "Partial match:", followed by the
592  partially matching substring.  partially matching substring. (Note that this is the entire substring that was
593    inspected during the partial match; it may include characters before the actual
594    match start if a lookbehind assertion, \eK, \eb, or \eB was involved.)
595  .P  .P
596  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
597  at the end of the longest match. For example:  at the end of the longest match. For example:
# Line 741  Cambridge CB2 3QH, England. Line 770  Cambridge CB2 3QH, England.
770  .rs  .rs
771  .sp  .sp
772  .nf  .nf
773  Last updated: 26 March 2010  Last updated: 01 November 2010
774  Copyright (c) 1997-2010 University of Cambridge.  Copyright (c) 1997-2010 University of Cambridge.
775  .fi  .fi

Legend:
Removed from v.510  
changed lines
  Added in v.566

  ViewVC Help
Powered by ViewVC 1.1.5