/[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 545 by ph10, Wed Jun 16 10:51:15 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  /L modifier must be followed directly by the name of a locale, for         The /D modifier is a PCRE debugging feature, and is equivalent to  /BI,
229         example,         that is, both the /B and the /I modifiers.
   
          /pattern/Lfr_FR  
230    
231         For this reason, it must be the last modifier. The given locale is set,         The /F modifier causes pcretest to flip the byte order of the fields in
232         pcre_maketables()  is called to build a set of character tables for the         the compiled pattern that  contain  2-byte  and  4-byte  numbers.  This
233         locale, and this is then passed to pcre_compile()  when  compiling  the         facility  is  for testing the feature in PCRE that allows it to execute
234         regular  expression.  Without  an  /L  modifier,  NULL is passed as the         patterns that were compiled on a host with a different endianness. This
235         tables pointer; that is, /L applies only to the expression on which  it         feature  is  not  available  when  the POSIX interface to PCRE is being
236         appears.         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         The  /I  modifier  requests  that pcretest output information about the
240         compiled pattern (whether it is anchored, has a fixed first  character,         compiled pattern (whether it is anchored, has a fixed first  character,
# Line 237  PATTERN MODIFIERS Line 242  PATTERN MODIFIERS
242         pattern. If the pattern is studied, the results of that are  also  out-         pattern. If the pattern is studied, the results of that are  also  out-
243         put.         put.
244    
245         The  /D modifier is a PCRE debugging feature, and is equivalent to /BI,         The  /K modifier requests pcretest to show names from backtracking con-
246         that is, both the /B and the /I modifiers.         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 /F modifier causes pcretest to flip the byte order of the fields in         The  /L modifier must be followed directly by the name of a locale, for
256         the  compiled  pattern  that  contain  2-byte  and 4-byte numbers. This         example,
        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.  
257    
258         The /S modifier causes pcre_study() to be called after  the  expression           /pattern/Lfr_FR
259         has been compiled, and the results used when the expression is matched.  
260           For this reason, it must be the last modifier. The given locale is set,
261           pcre_maketables()  is called to build a set of character tables for the
262           locale, and this is then passed to pcre_compile()  when  compiling  the
263           regular  expression.  Without an /L (or /T) modifier, NULL is passed as
264           the tables pointer; that is, /L applies only to the expression on which
265           it appears.
266    
267         The  /M  modifier causes the size of memory block used to hold the com-         The  /M  modifier causes the size of memory block used to hold the com-
268         piled pattern to be output.         piled pattern to be output.
269    
270         The /P modifier causes pcretest to call PCRE via the POSIX wrapper  API         The /S modifier causes pcre_study() to be called after  the  expression
271         rather  than  its  native  API.  When this is done, all other modifiers         has been compiled, and the results used when the expression is matched.
272         except /i, /m, and /+ are ignored. REG_ICASE is set if /i  is  present,  
273         and  REG_NEWLINE  is  set if /m is present. The wrapper functions force         The  /T  modifier  must be followed by a single digit. It causes a spe-
274         PCRE_DOLLAR_ENDONLY always, and PCRE_DOTALL unless REG_NEWLINE is set.         cific set of built-in character tables to be passed to  pcre_compile().
275           It is used in the standard PCRE tests to check behaviour with different
276         The /8 modifier causes pcretest to call PCRE with the PCRE_UTF8  option         character tables. The digit specifies the tables as follows:
277         set.  This  turns on support for UTF-8 character handling in PCRE, pro-  
278         vided that it was compiled with this  support  enabled.  This  modifier           0   the default ASCII tables, as distributed in
279         also causes any non-printing characters in output strings to be printed                 pcre_chartables.c.dist
280         using the \x{hh...} notation if they are valid UTF-8 sequences.           1   a set of tables defining ISO 8859 characters
281    
282         If the /? modifier  is  used  with  /8,  it  causes  pcretest  to  call         In table 1, some characters whose codes are greater than 128 are  iden-
283         pcre_compile()  with  the  PCRE_NO_UTF8_CHECK  option,  to suppress the         tified as letters, digits, spaces, etc.
284         checking of the string for UTF-8 validity.  
285       Using the POSIX wrapper API
286    
287           The  /P modifier causes pcretest to call PCRE via the POSIX wrapper API
288           rather than its native API. When /P is set, the following modifiers set
289           options for the regcomp() function:
290    
291             /i    REG_ICASE
292             /m    REG_NEWLINE
293             /N    REG_NOSUB
294             /s    REG_DOTALL     )
295             /U    REG_UNGREEDY   ) These options are not part of
296             /W    REG_UCP        )   the POSIX standard
297             /8    REG_UTF8       )
298    
299           The  /+  modifier  works  as  described  above. All other modifiers are
300           ignored.
301    
302    
303  DATA LINES  DATA LINES
# Line 382  DATA LINES Line 411  DATA LINES
411    
412         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-
413         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
414         effect are \B and \Z, causing REG_NOTBOL and REG_NOTEOL,  respectively,         effect are \B,  \N,  and  \Z,  causing  REG_NOTBOL,  REG_NOTEMPTY,  and
415         to be passed to regexec().         REG_NOTEOL, respectively, to be passed to regexec().
416    
417         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
418         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 692  AUTHOR
692    
693  REVISION  REVISION
694    
695         Last updated: 26 September 2009         Last updated: 14 June 2010
696         Copyright (c) 1997-2009 University of Cambridge.         Copyright (c) 1997-2010 University of Cambridge.

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

  ViewVC Help
Powered by ViewVC 1.1.5