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

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

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

revision 461 by ph10, Mon Oct 5 10:59:35 2009 UTC revision 535 by ph10, Thu Jun 3 19:18:24 2010 UTC
# Line 154  PATTERN MODIFIERS Line 154  PATTERN MODIFIERS
154    
155           /caseless/i           /caseless/i
156    
157         The following table shows additional modifiers for setting PCRE options         The  following  table  shows additional modifiers for setting PCRE com-
158         that do not correspond to anything in Perl:         pile-time options that do not correspond to anything in Perl:
159    
160             /8              PCRE_UTF8
161             /?              PCRE_NO_UTF8_CHECK
162           /A              PCRE_ANCHORED           /A              PCRE_ANCHORED
163           /C              PCRE_AUTO_CALLOUT           /C              PCRE_AUTO_CALLOUT
164           /E              PCRE_DOLLAR_ENDONLY           /E              PCRE_DOLLAR_ENDONLY
# Line 164  PATTERN MODIFIERS Line 166  PATTERN MODIFIERS
166           /J              PCRE_DUPNAMES           /J              PCRE_DUPNAMES
167           /N              PCRE_NO_AUTO_CAPTURE           /N              PCRE_NO_AUTO_CAPTURE
168           /U              PCRE_UNGREEDY           /U              PCRE_UNGREEDY
169             /W              PCRE_UCP
170           /X              PCRE_EXTRA           /X              PCRE_EXTRA
171           /<JS>           PCRE_JAVASCRIPT_COMPAT           /<JS>           PCRE_JAVASCRIPT_COMPAT
172           /<cr>           PCRE_NEWLINE_CR           /<cr>           PCRE_NEWLINE_CR
# Line 174  PATTERN MODIFIERS Line 177  PATTERN MODIFIERS
177           /<bsr_anycrlf>  PCRE_BSR_ANYCRLF           /<bsr_anycrlf>  PCRE_BSR_ANYCRLF
178           /<bsr_unicode>  PCRE_BSR_UNICODE           /<bsr_unicode>  PCRE_BSR_UNICODE
179    
180         Those specifying line ending sequences are literal  strings  as  shown,         The modifiers that are enclosed in angle brackets are  literal  strings
181         but  the  letters  can  be  in either case. This example sets multiline         as  shown,  including  the  angle  brackets,  but the letters can be in
182         matching with CRLF as the line ending sequence:         either case. This example sets multiline matching with CRLF as the line
183           ending sequence:
184    
185           /^abc/m<crlf>           /^abc/m<crlf>
186    
187         Details of the meanings of these PCRE options are given in the  pcreapi         As well as turning on the PCRE_UTF8 option, the /8 modifier also causes
188         documentation.         any non-printing characters in output strings to be printed  using  the
189           \x{hh...}  notation  if they are valid UTF-8 sequences. Full details of
190           the PCRE options are given in the pcreapi documentation.
191    
192     Finding all matches in a string     Finding all matches in a string
193    
194         Searching  for  all  possible matches within each subject string can be         Searching for all possible matches within each subject  string  can  be
195         requested by the /g or /G modifier. After  finding  a  match,  PCRE  is         requested  by  the  /g  or  /G modifier. After finding a match, PCRE is
196         called again to search the remainder of the subject string. The differ-         called again to search the remainder of the subject string. The differ-
197         ence between /g and /G is that the former uses the startoffset argument         ence between /g and /G is that the former uses the startoffset argument
198         to  pcre_exec()  to  start  searching  at a new point within the entire         to pcre_exec() to start searching at a  new  point  within  the  entire
199         string (which is in effect what Perl does), whereas the  latter  passes         string  (which  is in effect what Perl does), whereas the latter passes
200         over  a  shortened  substring.  This makes a difference to the matching         over a shortened substring. This makes a  difference  to  the  matching
201         process if the pattern begins with a lookbehind assertion (including \b         process if the pattern begins with a lookbehind assertion (including \b
202         or \B).         or \B).
203    
204         If  any  call  to  pcre_exec()  in a /g or /G sequence matches an empty         If any call to pcre_exec() in a /g or  /G  sequence  matches  an  empty
205         string, the next  call  is  done  with  the  PCRE_NOTEMPTY_ATSTART  and         string,  the  next  call  is  done  with  the PCRE_NOTEMPTY_ATSTART and
206         PCRE_ANCHORED  flags  set  in  order  to search for another, non-empty,         PCRE_ANCHORED flags set in order  to  search  for  another,  non-empty,
207         match at the same point. If this second match fails, the  start  offset         match  at  the same point. If this second match fails, the start offset
208         is  advanced  by  one  character, and the normal match is retried. This         is advanced by one character, and the normal  match  is  retried.  This
209         imitates the way Perl handles such cases when using the /g modifier  or         imitates  the way Perl handles such cases when using the /g modifier or
210         the split() function.         the split() function.
211    
212     Other modifiers     Other modifiers
213    
214         There are yet more modifiers for controlling the way pcretest operates.         There are yet more modifiers for controlling the way pcretest operates.
215    
216         The  /+ modifier requests that as well as outputting the substring that         The /+ modifier requests that as well as outputting the substring  that
217         matched the entire pattern, pcretest  should  in  addition  output  the         matched  the  entire  pattern,  pcretest  should in addition output the
218         remainder  of  the  subject  string. This is useful for tests where the         remainder of the subject string. This is useful  for  tests  where  the
219         subject contains multiple copies of the same substring.         subject contains multiple copies of the same substring.
220    
221         The /B modifier is a debugging feature. It requests that pcretest  out-         The  /B modifier is a debugging feature. It requests that pcretest out-
222         put  a representation of the compiled byte code after compilation. Nor-         put a representation of the compiled byte code after compilation.  Nor-
223         mally this information contains length and offset values;  however,  if         mally  this  information contains length and offset values; however, if
224         /Z  is also present, this data is replaced by spaces. This is a special         /Z is also present, this data is replaced by spaces. This is a  special
225         feature for use in the automatic test scripts; it ensures that the same         feature for use in the automatic test scripts; it ensures that the same
226         output is generated for different internal link sizes.         output is generated for different internal link sizes.
227    
228           The /D modifier is a PCRE debugging feature, and is equivalent to  /BI,
229           that is, both the /B and the /I modifiers.
230    
231           The /F modifier causes pcretest to flip the byte order of the fields in
232           the compiled pattern that  contain  2-byte  and  4-byte  numbers.  This
233           facility  is  for testing the feature in PCRE that allows it to execute
234           patterns that were compiled on a host with a different endianness. This
235           feature  is  not  available  when  the POSIX interface to PCRE is being
236           used, that is, when the /P pattern modifier is specified. See also  the
237           section about saving and reloading compiled patterns below.
238    
239           The  /I  modifier  requests  that pcretest output information about the
240           compiled pattern (whether it is anchored, has a fixed first  character,
241           and  so  on). It does this by calling pcre_fullinfo() after compiling a
242           pattern. If the pattern is studied, the results of that are  also  out-
243           put.
244    
245           The  /K modifier requests pcretest to show names from backtracking con-
246           trol verbs that are returned  from  calls  to  pcre_exec().  It  causes
247           pcretest  to create a pcre_extra block if one has not already been cre-
248           ated by a call to pcre_study(), and to set the PCRE_EXTRA_MARK flag and
249           the mark field within it, every time that pcre_exec() is called. If the
250           variable that the mark field points to is non-NULL for  a  match,  non-
251           match, or partial match, pcretest prints the string to which it points.
252           For a match, this is shown on a line by itself, tagged with "MK:".  For
253           a non-match it is added to the message.
254    
255         The  /L modifier must be followed directly by the name of a locale, for         The  /L modifier must be followed directly by the name of a locale, for
256         example,         example,
257    
# Line 231  PATTERN MODIFIERS Line 264  PATTERN MODIFIERS
264         tables pointer; that is, /L applies only to the expression on which  it         tables pointer; that is, /L applies only to the expression on which  it
265         appears.         appears.
266    
267         The  /I  modifier  requests  that pcretest output information about the         The  /M  modifier causes the size of memory block used to hold the com-
268         compiled pattern (whether it is anchored, has a fixed first  character,         piled pattern to be output.
        and  so  on). It does this by calling pcre_fullinfo() after compiling a  
        pattern. If the pattern is studied, the results of that are  also  out-  
        put.  
   
        The  /D modifier is a PCRE debugging feature, and is equivalent to /BI,  
        that is, both the /B and the /I modifiers.  
   
        The /F modifier causes pcretest to flip the byte order of the fields in  
        the  compiled  pattern  that  contain  2-byte  and 4-byte numbers. This  
        facility is for testing the feature in PCRE that allows it  to  execute  
        patterns that were compiled on a host with a different endianness. This  
        feature is not available when the POSIX  interface  to  PCRE  is  being  
        used,  that is, when the /P pattern modifier is specified. See also the  
        section about saving and reloading compiled patterns below.  
269    
270         The /S modifier causes pcre_study() to be called after  the  expression         The /S modifier causes pcre_study() to be called after  the  expression
271         has been compiled, and the results used when the expression is matched.         has been compiled, and the results used when the expression is matched.
272    
273         The  /M  modifier causes the size of memory block used to hold the com-     Using the POSIX wrapper API
274         piled pattern to be output.  
275           The  /P modifier causes pcretest to call PCRE via the POSIX wrapper API
276           rather than its native API. When /P is set, the following modifiers set
277           options for the regcomp() function:
278    
279             /i    REG_ICASE
280             /m    REG_NEWLINE
281             /N    REG_NOSUB
282             /s    REG_DOTALL     )
283             /U    REG_UNGREEDY   ) These options are not part of
284             /W    REG_UCP        )   the POSIX standard
285             /8    REG_UTF8       )
286    
287         The /P modifier causes pcretest to call PCRE via the POSIX wrapper  API         The  /+  modifier  works  as  described  above. All other modifiers are
288         rather  than  its  native  API.  When this is done, all other modifiers         ignored.
        except /i, /m, and /+ are ignored. REG_ICASE is set if /i  is  present,  
        and  REG_NEWLINE  is  set if /m is present. The wrapper functions force  
        PCRE_DOLLAR_ENDONLY always, and PCRE_DOTALL unless REG_NEWLINE is set.  
   
        The /8 modifier causes pcretest to call PCRE with the PCRE_UTF8  option  
        set.  This  turns on support for UTF-8 character handling in PCRE, pro-  
        vided that it was compiled with this  support  enabled.  This  modifier  
        also causes any non-printing characters in output strings to be printed  
        using the \x{hh...} notation if they are valid UTF-8 sequences.  
   
        If the /? modifier  is  used  with  /8,  it  causes  pcretest  to  call  
        pcre_compile()  with  the  PCRE_NO_UTF8_CHECK  option,  to suppress the  
        checking of the string for UTF-8 validity.  
289    
290    
291  DATA LINES  DATA LINES
# Line 382  DATA LINES Line 399  DATA LINES
399    
400         If the /P modifier was present on the pattern, causing the POSIX  wrap-         If the /P modifier was present on the pattern, causing the POSIX  wrap-
401         per  API  to  be  used, the only option-setting sequences that have any         per  API  to  be  used, the only option-setting sequences that have any
402         effect are \B and \Z, causing REG_NOTBOL and REG_NOTEOL,  respectively,         effect are \B,  \N,  and  \Z,  causing  REG_NOTBOL,  REG_NOTEMPTY,  and
403         to be passed to regexec().         REG_NOTEOL, respectively, to be passed to regexec().
404    
405         The  use of \x{hh...} to represent UTF-8 characters is not dependent on         The  use of \x{hh...} to represent UTF-8 characters is not dependent on
406         the use of the /8 modifier on the pattern.  It  is  recognized  always.         the use of the /8 modifier on the pattern.  It  is  recognized  always.
# Line 663  AUTHOR Line 680  AUTHOR
680    
681  REVISION  REVISION
682    
683         Last updated: 26 September 2009         Last updated: 16 May 2010
684         Copyright (c) 1997-2009 University of Cambridge.         Copyright (c) 1997-2010 University of Cambridge.

Legend:
Removed from v.461  
changed lines
  Added in v.535

  ViewVC Help
Powered by ViewVC 1.1.5