/[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 930 by ph10, Fri Feb 24 12:05:54 2012 UTC revision 1194 by ph10, Wed Oct 31 17:42:29 2012 UTC
# Line 14  SYNOPSIS Line 14  SYNOPSIS
14         expressions.  This document describes the features of the test program;         expressions.  This document describes the features of the test program;
15         for details of the regular expressions themselves, see the  pcrepattern         for details of the regular expressions themselves, see the  pcrepattern
16         documentation. For details of the PCRE library function calls and their         documentation. For details of the PCRE library function calls and their
17         options, see the  pcreapi  and  pcre16  documentation.  The  input  for         options, see the pcreapi , pcre16 and pcre32 documentation.
        pcretest is a sequence of regular expression patterns and strings to be  
        matched, as described below. The output shows the result of each match.  
        Options  on  the command line and the patterns control PCRE options and  
        exactly what is output.  
18    
19           The input for pcretest is a sequence of regular expression patterns and
20           strings  to be matched, as described below. The output shows the result
21           of each match. Options on the command line  and  the  patterns  control
22           PCRE options and exactly what is output.
23    
24           As  PCRE has evolved, it has acquired many different features, and as a
25           result, pcretest now has rather a lot of obscure  options  for  testing
26           every possible feature. Some of these options are specifically designed
27           for use in conjunction with the test script and  data  files  that  are
28           distributed  as  part of PCRE, and are unlikely to be of use otherwise.
29           They are all documented here, but without much justification.
30    
31  PCRE's 8-BIT and 16-BIT LIBRARIES  
32    PCRE's 8-BIT, 16-BIT AND 32-BIT LIBRARIES
33    
34         From release 8.30, two separate PCRE libraries can be built. The origi-         From release 8.30, two separate PCRE libraries can be built. The origi-
35         nal  one  supports  8-bit  character  strings, whereas the newer 16-bit         nal  one  supports  8-bit  character  strings, whereas the newer 16-bit
36         library  supports  character  strings  encoded  in  16-bit  units.  The         library supports  character  strings  encoded  in  16-bit  units.  From
37         pcretest  program  can  be  used to test both libraries. However, it is         release  8.32,  a  third  library  can  be  built, supporting character
38         itself still an 8-bit program, reading 8-bit input  and  writing  8-bit         strings encoded in 32-bit units.  The pcretest program can be  used  to
39         output.  When testing the 16-bit library, the patterns and data strings         test all three libraries. However, it is itself still an 8-bit program,
40         are converted to 16-bit format before being passed to the PCRE  library         reading 8-bit input and writing 8-bit output. When testing  the  16-bit
41         functions. Results are converted to 8-bit for output.         or  32-bit  library, the patterns and data strings are converted to 16-
42           or 32-bit format before being passed to  the  PCRE  library  functions.
43           Results are converted to 8-bit for output.
44    
45         References  to  functions  and structures of the form pcre[16]_xx below         References to functions and structures of the form pcre[16|32]_xx below
46         mean "pcre_xx when using the 8-bit library or pcre16_xx when using  the         mean "pcre_xx when using the 8-bit library or pcre16_xx when using  the
47         16-bit library".         16-bit library".
48    
49    
50  COMMAND LINE OPTIONS  COMMAND LINE OPTIONS
51    
52         -16       If  both  the 8-bit and the 16-bit libraries have been built,         -8        If  both the 8-bit library has been built, this option causes
53                   this option causes the 16-bit library to be used. If only the                   the 8-bit library to be used (which is the default);  if  the
54                   16-bit library has been built, this is the default (so has no                   8-bit  library  has  not  been  built,  this option causes an
55                   effect). If only the  8-bit  library  has  been  built,  this                   error.
56                   option causes an error.  
57           -16       If both the 8-bit or the 32-bit,  and  the  16-bit  libraries
58                     have  been built, this option causes the 16-bit library to be
59                     used. If only the 16-bit library has been built, this is  the
60                     default  (so  has no effect). If only the 8-bit or the 32-bit
61                     library has been built, this option causes an error.
62    
63           -32       If both the 8-bit or the 16-bit,  and  the  32-bit  libraries
64                     have  been built, this option causes the 32-bit library to be
65                     used. If only the 32-bit library has been built, this is  the
66                     default  (so  has no effect). If only the 8-bit or the 16-bit
67                     library has been built, this option causes an error.
68    
69         -b        Behave  as  if each pattern has the /B (show byte code) modi-         -b        Behave as if each pattern has the /B (show byte  code)  modi-
70                   fier; the internal form is output after compilation.                   fier; the internal form is output after compilation.
71    
72         -C        Output the version number of the PCRE library, and all avail-         -C        Output the version number of the PCRE library, and all avail-
73                   able   information  about  the  optional  features  that  are                   able  information  about  the  optional  features  that   are
74                   included, and then exit. All other options are ignored.                   included, and then exit. All other options are ignored.
75    
76         -C option Output information about a specific build-time  option,  then         -C option Output  information  about a specific build-time option, then
77                   exit.  This functionality is intended for use in scripts such                   exit. This functionality is intended for use in scripts  such
78                   as RunTest. The following options output the value indicated:                   as RunTest. The following options output the value indicated:
79    
80                       ebcdic-nl  the code for LF (= NL) in an EBCDIC environment:
81                                    0x15 or 0x25
82                                    0 if used in an ASCII environment
83                     linksize   the internal link size (2, 3, or 4)                     linksize   the internal link size (2, 3, or 4)
84                     newline    the default newline setting:                     newline    the default newline setting:
85                                  CR, LF, CRLF, ANYCRLF, or ANY                                  CR, LF, CRLF, ANYCRLF, or ANY
86    
87                   The following options output 1 for true or zero for false:                   The following options output 1 for true or zero for false:
88    
89                       ebcdic     compiled for an EBCDIC environment
90                     jit        just-in-time support is available                     jit        just-in-time support is available
91                     pcre16     the 16-bit library was built                     pcre16     the 16-bit library was built
92                       pcre32     the 32-bit library was built
93                     pcre8      the 8-bit library was built                     pcre8      the 8-bit library was built
94                     ucp        Unicode property support is available                     ucp        Unicode property support is available
95                     utf        UTF-8 and/or UTF-16 support is available                     utf         UTF-8  and/or  UTF-16  and/or UTF-32 support is
96                     available
97    
98         -d        Behave as if each pattern has the /D  (debug)  modifier;  the         -d        Behave as if each pattern has the /D  (debug)  modifier;  the
99                   internal  form  and information about the compiled pattern is                   internal  form  and information about the compiled pattern is
# Line 74  COMMAND LINE OPTIONS Line 101  COMMAND LINE OPTIONS
101    
102         -dfa      Behave as if each data line contains the \D escape  sequence;         -dfa      Behave as if each data line contains the \D escape  sequence;
103                   this    causes    the    alternative    matching    function,                   this    causes    the    alternative    matching    function,
104                   pcre[16]_dfa_exec(), to  be  used  instead  of  the  standard                   pcre[16|32]_dfa_exec(), to be used instead  of  the  standard
105                   pcre[16]_exec() function (more detail is given below).                   pcre[16|32]_exec() function (more detail is given below).
106    
107         -help     Output a brief summary these options and then exit.         -help     Output a brief summary these options and then exit.
108    
# Line 84  COMMAND LINE OPTIONS Line 111  COMMAND LINE OPTIONS
111    
112         -M        Behave as if each data line contains the \M escape  sequence;         -M        Behave as if each data line contains the \M escape  sequence;
113                   this  causes  PCRE  to  discover  the minimum MATCH_LIMIT and                   this  causes  PCRE  to  discover  the minimum MATCH_LIMIT and
114                   MATCH_LIMIT_RECURSION  settings  by  calling  pcre[16]_exec()                   MATCH_LIMIT_RECURSION settings by calling  pcre[16|32]_exec()
115                   repeatedly with different limits.                   repeatedly with different limits.
116    
117         -m        Output  the  size  of each compiled pattern after it has been         -m        Output  the  size  of each compiled pattern after it has been
# Line 92  COMMAND LINE OPTIONS Line 119  COMMAND LINE OPTIONS
119                   expression. The size is given in bytes for both libraries.                   expression. The size is given in bytes for both libraries.
120    
121         -o osize  Set  the number of elements in the output vector that is used         -o osize  Set  the number of elements in the output vector that is used
122                   when calling pcre[16]_exec()  or  pcre[16]_dfa_exec()  to  be                   when calling pcre[16|32]_exec() or pcre[16|32]_dfa_exec()  to
123                   osize.  The  default value is 45, which is enough for 14 cap-                   be  osize.  The  default  value is 45, which is enough for 14
124                   turing subexpressions for  pcre[16]_exec()  or  22  different                   capturing subexpressions for pcre[16|32]_exec() or 22 differ-
125                   matches  for  pcre[16]_dfa_exec().   The  vector  size can be                   ent  matches for pcre[16|32]_dfa_exec().  The vector size can
126                   changed for individual matching calls by including \O in  the                   be changed for individual matching calls by including  \O  in
127                   data line (see below).                   the data line (see below).
128    
129         -p        Behave  as  if  each  pattern  has the /P modifier; the POSIX         -p        Behave  as  if  each  pattern  has the /P modifier; the POSIX
130                   wrapper API is used to call PCRE. None of the  other  options                   wrapper API is used to call PCRE. None of the  other  options
# Line 112  COMMAND LINE OPTIONS Line 139  COMMAND LINE OPTIONS
139    
140         -s or -s+ Behave as if each pattern  has  the  /S  modifier;  in  other         -s or -s+ Behave as if each pattern  has  the  /S  modifier;  in  other
141                   words,  force each pattern to be studied. If -s+ is used, all                   words,  force each pattern to be studied. If -s+ is used, all
142                   the JIT compile options are passed to pcre[16]_study(), caus-                   the JIT compile options are  passed  to  pcre[16|32]_study(),
143                   ing  just-in-time  optimization  to be set up if it is avail-                   causing  just-in-time  optimization  to  be  set  up if it is
144                   able, for both full and partial matching. Specific  JIT  com-                   available, for both full and partial matching.  Specific  JIT
145                   pile options can be selected by following -s+ with a digit in                   compile options can be selected by following -s+ with a digit
146                   the range 1 to 7, which selects the JIT compile modes as fol-                   in the range 1 to 7, which selects the JIT compile  modes  as
147                   lows:                   follows:
148    
149                     1  normal match only                     1  normal match only
150                     2  soft partial match only                     2  soft partial match only
# Line 131  COMMAND LINE OPTIONS Line 158  COMMAND LINE OPTIONS
158                   after a match or no match when JIT-compiled code was actually                   after a match or no match when JIT-compiled code was actually
159                   used.                   used.
160    
161         If the /I or /D option is present on a pattern (requesting output about                   Note that there are pattern options  that  can  override  -s,
162         the  compiled pattern), information about the result of studying is not                   either specifying no studying at all, or suppressing JIT com-
163         included when studying is caused only by -s and neither -i  nor  -d  is                   pilation.
164         present  on the command line. This behaviour means that the output from  
165         tests that are run with and without -s should be identical, except when                   If the /I or /D option is present on  a  pattern  (requesting
166         options that output information about the actual running of a match are                   output  about  the  compiled  pattern), information about the
167         set.                   result of studying is not included when  studying  is  caused
168                     only  by  -s  and neither -i nor -d is present on the command
169         The -M, -t, and -tm options, which  give  information  about  resources                   line. This behaviour means that the output  from  tests  that
170         used,  are likely to produce different output with and without -s. Out-                   are  run with and without -s should be identical, except when
171         put may also differ if the /C option is present on an  individual  pat-                   options that output information about the actual running of a
172         tern.  This  uses  callouts to trace the the matching process, and this                   match are set.
173         may be different between studied and non-studied patterns. If the  pat-  
174         tern contains (*MARK) items there may also be differences, for the same                   The  -M,  -t,  and  -tm options, which give information about
175         reason. The -s command line option can be overridden for specific  pat-                   resources used, are likely to produce different  output  with
176         terns that should never be studied (see the /S pattern modifier below).                   and  without  -s.  Output may also differ if the /C option is
177                     present on an individual pattern. This uses callouts to trace
178         -t        Run  each  compile, study, and match many times with a timer,                   the  the  matching process, and this may be different between
179                   and output resulting time per compile or match (in  millisec-                   studied and non-studied patterns.  If  the  pattern  contains
180                   onds).  Do  not set -m with -t, because you will then get the                   (*MARK)  items  there  may  also be differences, for the same
181                   size output a zillion times, and  the  timing  will  be  dis-                   reason. The -s command line option can be overridden for spe-
182                   torted.  You  can  control  the number of iterations that are                   cific  patterns that should never be studied (see the /S pat-
183                   used for timing by following -t with a number (as a  separate                   tern modifier below).
184    
185           -t        Run each compile, study, and match many times with  a  timer,
186                     and  output resulting time per compile or match (in millisec-
187                     onds). Do not set -m with -t, because you will then  get  the
188                     size  output  a  zillion  times,  and the timing will be dis-
189                     torted. You can control the number  of  iterations  that  are
190                     used  for timing by following -t with a number (as a separate
191                   item on the command line). For example, "-t 1000" would iter-                   item on the command line). For example, "-t 1000" would iter-
192                   ate 1000 times. The default is to iterate 500000 times.                   ate 1000 times. The default is to iterate 500000 times.
193    
# Line 163  COMMAND LINE OPTIONS Line 197  COMMAND LINE OPTIONS
197    
198  DESCRIPTION  DESCRIPTION
199    
200         If  pcretest  is  given two filename arguments, it reads from the first         If pcretest is given two filename arguments, it reads  from  the  first
201         and writes to the second. If it is given only one filename argument, it         and writes to the second. If it is given only one filename argument, it
202         reads  from  that  file  and writes to stdout. Otherwise, it reads from         reads from that file and writes to stdout.  Otherwise,  it  reads  from
203         stdin and writes to stdout, and prompts for each line of  input,  using         stdin  and  writes to stdout, and prompts for each line of input, using
204         "re>" to prompt for regular expressions, and "data>" to prompt for data         "re>" to prompt for regular expressions, and "data>" to prompt for data
205         lines.         lines.
206    
207         When pcretest is built, a configuration  option  can  specify  that  it         When  pcretest  is  built,  a  configuration option can specify that it
208         should  be  linked  with the libreadline library. When this is done, if         should be linked with the libreadline library. When this  is  done,  if
209         the input is from a terminal, it is read using the readline() function.         the input is from a terminal, it is read using the readline() function.
210         This  provides line-editing and history facilities. The output from the         This provides line-editing and history facilities. The output from  the
211         -help option states whether or not readline() will be used.         -help option states whether or not readline() will be used.
212    
213         The program handles any number of sets of input on a single input file.         The program handles any number of sets of input on a single input file.
214         Each  set starts with a regular expression, and continues with any num-         Each set starts with a regular expression, and continues with any  num-
215         ber of data lines to be matched against the pattern.         ber of data lines to be matched against the pattern.
216    
217         Each data line is matched separately and independently. If you want  to         Each  data line is matched separately and independently. If you want to
218         do multi-line matches, you have to use the \n escape sequence (or \r or         do multi-line matches, you have to use the \n escape sequence (or \r or
219         \r\n, etc., depending on the newline setting) in a single line of input         \r\n, etc., depending on the newline setting) in a single line of input
220         to  encode  the  newline  sequences. There is no limit on the length of         to encode the newline sequences. There is no limit  on  the  length  of
221         data lines; the input buffer is automatically extended  if  it  is  too         data  lines;  the  input  buffer is automatically extended if it is too
222         small.         small.
223    
224         An  empty  line signals the end of the data lines, at which point a new         An empty line signals the end of the data lines, at which point  a  new
225         regular expression is read. The regular expressions are given  enclosed         regular  expression is read. The regular expressions are given enclosed
226         in any non-alphanumeric delimiters other than backslash, for example:         in any non-alphanumeric delimiters other than backslash, for example:
227    
228           /(a|bc)x+yz/           /(a|bc)x+yz/
229    
230         White  space before the initial delimiter is ignored. A regular expres-         White space before the initial delimiter is ignored. A regular  expres-
231         sion may be continued over several input lines, in which case the  new-         sion  may be continued over several input lines, in which case the new-
232         line  characters  are included within it. It is possible to include the         line characters are included within it. It is possible to  include  the
233         delimiter within the pattern by escaping it, for example         delimiter within the pattern by escaping it, for example
234    
235           /abc\/def/           /abc\/def/
236    
237         If you do so, the escape and the delimiter form part  of  the  pattern,         If  you  do  so, the escape and the delimiter form part of the pattern,
238         but  since delimiters are always non-alphanumeric, this does not affect         but since delimiters are always non-alphanumeric, this does not  affect
239         its interpretation.  If the terminating delimiter is  immediately  fol-         its  interpretation.   If the terminating delimiter is immediately fol-
240         lowed by a backslash, for example,         lowed by a backslash, for example,
241    
242           /abc/\           /abc/\
243    
244         then  a  backslash  is added to the end of the pattern. This is done to         then a backslash is added to the end of the pattern. This  is  done  to
245         provide a way of testing the error condition that arises if  a  pattern         provide  a  way of testing the error condition that arises if a pattern
246         finishes with a backslash, because         finishes with a backslash, because
247    
248           /abc\/           /abc\/
249    
250         is  interpreted as the first line of a pattern that starts with "abc/",         is interpreted as the first line of a pattern that starts with  "abc/",
251         causing pcretest to read the next line as a continuation of the regular         causing pcretest to read the next line as a continuation of the regular
252         expression.         expression.
253    
254    
255  PATTERN MODIFIERS  PATTERN MODIFIERS
256    
257         A  pattern may be followed by any number of modifiers, which are mostly         A pattern may be followed by any number of modifiers, which are  mostly
258         single characters. Following Perl usage, these are  referred  to  below         single  characters,  though  some  of these can be qualified by further
259         as,  for  example,  "the /i modifier", even though the delimiter of the         characters.  Following Perl usage, these are referred to below as,  for
260         pattern need not always be a slash, and no slash is used  when  writing         example,  "the  /i  modifier", even though the delimiter of the pattern
261         modifiers.  White  space may appear between the final pattern delimiter         need not always be a slash, and no slash is  used  when  writing  modi-
262         and the first modifier, and between the modifiers themselves.         fiers.  White  space may appear between the final pattern delimiter and
263           the first modifier, and between the modifiers  themselves.  For  refer-
264           ence,  here  is  a  complete  list of modifiers. They fall into several
265           groups that are described in detail in the following sections.
266    
267             /8              set UTF mode
268             /?              disable UTF validity check
269             /+              show remainder of subject after match
270             /=              show all captures (not just those that are set)
271    
272             /A              set PCRE_ANCHORED
273             /B              show compiled code
274             /C              set PCRE_AUTO_CALLOUT
275             /D              same as /B plus /I
276             /E              set PCRE_DOLLAR_ENDONLY
277             /F              flip byte order in compiled pattern
278             /f              set PCRE_FIRSTLINE
279             /G              find all matches (shorten string)
280             /g              find all matches (use startoffset)
281             /I              show information about pattern
282             /i              set PCRE_CASELESS
283             /J              set PCRE_DUPNAMES
284             /K              show backtracking control names
285             /L              set locale
286             /M              show compiled memory size
287             /m              set PCRE_MULTILINE
288             /N              set PCRE_NO_AUTO_CAPTURE
289             /P              use the POSIX wrapper
290             /S              study the pattern after compilation
291             /s              set PCRE_DOTALL
292             /T              select character tables
293             /U              set PCRE_UNGREEDY
294             /W              set PCRE_UCP
295             /X              set PCRE_EXTRA
296             /x              set PCRE_EXTENDED
297             /Y              set PCRE_NO_START_OPTIMIZE
298             /Z              don't show lengths in /B output
299    
300             /<any>          set PCRE_NEWLINE_ANY
301             /<anycrlf>      set PCRE_NEWLINE_ANYCRLF
302             /<cr>           set PCRE_NEWLINE_CR
303             /<crlf>         set PCRE_NEWLINE_CRLF
304             /<lf>           set PCRE_NEWLINE_LF
305             /<bsr_anycrlf>  set PCRE_BSR_ANYCRLF
306             /<bsr_unicode>  set PCRE_BSR_UNICODE
307             /<JS>           set PCRE_JAVASCRIPT_COMPAT
308    
309    
310       Perl-compatible modifiers
311    
312         The /i, /m, /s, and /x modifiers set the PCRE_CASELESS, PCRE_MULTILINE,         The /i, /m, /s, and /x modifiers set the PCRE_CASELESS, PCRE_MULTILINE,
313         PCRE_DOTALL, or PCRE_EXTENDED options, respectively, when pcre[16]_com-         PCRE_DOTALL,    or    PCRE_EXTENDED    options,    respectively,   when
314         pile() is called. These four modifier letters have the same  effect  as         pcre[16|32]_compile() is called. These four modifier letters  have  the
315         they do in Perl. For example:         same effect as they do in Perl. For example:
316    
317           /caseless/i           /caseless/i
318    
319    
320       Modifiers for other PCRE options
321    
322         The  following  table  shows additional modifiers for setting PCRE com-         The  following  table  shows additional modifiers for setting PCRE com-
323         pile-time options that do not correspond to anything in Perl:         pile-time options that do not correspond to anything in Perl:
324    
# Line 243  PATTERN MODIFIERS Line 328  PATTERN MODIFIERS
328           /8              PCRE_UTF16          ) when using the 16-bit           /8              PCRE_UTF16          ) when using the 16-bit
329           /?              PCRE_NO_UTF16_CHECK )   library           /?              PCRE_NO_UTF16_CHECK )   library
330    
331             /8              PCRE_UTF32          ) when using the 32-bit
332             /?              PCRE_NO_UTF32_CHECK )   library
333    
334           /A              PCRE_ANCHORED           /A              PCRE_ANCHORED
335           /C              PCRE_AUTO_CALLOUT           /C              PCRE_AUTO_CALLOUT
336           /E              PCRE_DOLLAR_ENDONLY           /E              PCRE_DOLLAR_ENDONLY
# Line 253  PATTERN MODIFIERS Line 341  PATTERN MODIFIERS
341           /W              PCRE_UCP           /W              PCRE_UCP
342           /X              PCRE_EXTRA           /X              PCRE_EXTRA
343           /Y              PCRE_NO_START_OPTIMIZE           /Y              PCRE_NO_START_OPTIMIZE
344           /<JS>           PCRE_JAVASCRIPT_COMPAT           /<any>          PCRE_NEWLINE_ANY
345             /<anycrlf>      PCRE_NEWLINE_ANYCRLF
346           /<cr>           PCRE_NEWLINE_CR           /<cr>           PCRE_NEWLINE_CR
          /<lf>           PCRE_NEWLINE_LF  
347           /<crlf>         PCRE_NEWLINE_CRLF           /<crlf>         PCRE_NEWLINE_CRLF
348           /<anycrlf>      PCRE_NEWLINE_ANYCRLF           /<lf>           PCRE_NEWLINE_LF
          /<any>          PCRE_NEWLINE_ANY  
349           /<bsr_anycrlf>  PCRE_BSR_ANYCRLF           /<bsr_anycrlf>  PCRE_BSR_ANYCRLF
350           /<bsr_unicode>  PCRE_BSR_UNICODE           /<bsr_unicode>  PCRE_BSR_UNICODE
351             /<JS>           PCRE_JAVASCRIPT_COMPAT
352    
353         The modifiers that are enclosed in angle brackets are  literal  strings         The modifiers that are enclosed in angle brackets are  literal  strings
354         as  shown,  including the angle brackets, but the letters within can be         as  shown,  including the angle brackets, but the letters within can be
# Line 269  PATTERN MODIFIERS Line 357  PATTERN MODIFIERS
357    
358           /^abc/m<CRLF>           /^abc/m<CRLF>
359    
360         As  well  as turning on the PCRE_UTF8/16 option, the /8 modifier causes         As  well  as  turning  on  the  PCRE_UTF8/16/32 option, the /8 modifier
361         all non-printing characters in output strings to be printed  using  the         causes all non-printing characters in  output  strings  to  be  printed
362         \x{hh...}  notation. Otherwise, those less than 0x100 are output in hex         using the \x{hh...} notation. Otherwise, those less than 0x100 are out-
363         without the curly brackets.         put in hex without the curly brackets.
364    
365         Full details of the PCRE options are given in  the  pcreapi  documenta-         Full details of the PCRE options are given in  the  pcreapi  documenta-
366         tion.         tion.
# Line 283  PATTERN MODIFIERS Line 371  PATTERN MODIFIERS
371         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
372         called again to search the remainder of the subject string. The differ-         called again to search the remainder of the subject string. The differ-
373         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
374         to  pcre[16]_exec() to start searching at a new point within the entire         to  pcre[16|32]_exec()  to  start  searching  at a new point within the
375         string (which is in effect what Perl does), whereas the  latter  passes         entire string (which is in effect what Perl does), whereas  the  latter
376         over  a  shortened  substring.  This makes a difference to the matching         passes  over  a  shortened  substring.  This  makes a difference to the
377         process if the pattern begins with a lookbehind assertion (including \b         matching process if the pattern  begins  with  a  lookbehind  assertion
378         or \B).         (including \b or \B).
379    
380         If  any call to pcre[16]_exec() in a /g or /G sequence matches an empty         If  any  call  to  pcre[16|32]_exec() in a /g or /G sequence matches an
381         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
382         PCRE_ANCHORED  flags  set  in  order  to search for another, non-empty,         PCRE_ANCHORED  flags  set  in  order  to search for another, non-empty,
383         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
384         is  advanced,  and  the  normal match is retried. This imitates the way         is  advanced,  and  the  normal match is retried. This imitates the way
# Line 316  PATTERN MODIFIERS Line 404  PATTERN MODIFIERS
404         The  /=  modifier  requests  that  the values of all potential captured         The  /=  modifier  requests  that  the values of all potential captured
405         parentheses be output after a match. By default, only those up  to  the         parentheses be output after a match. By default, only those up  to  the
406         highest one actually used in the match are output (corresponding to the         highest one actually used in the match are output (corresponding to the
407         return code from pcre[16]_exec()). Values in the offsets vector  corre-         return code from pcre[16|32]_exec()). Values in the offsets vector cor-
408         sponding to higher numbers should be set to -1, and these are output as         responding  to higher numbers should be set to -1, and these are output
409         "<unset>". This modifier gives a way of checking that this  is  happen-         as "<unset>". This modifier gives a way of checking that this  is  hap-
410         ing.         pening.
411    
412         The  /B modifier is a debugging feature. It requests that pcretest out-         The  /B modifier is a debugging feature. It requests that pcretest out-
413         put a representation of the compiled code after  compilation.  Normally         put a representation of the compiled code after  compilation.  Normally
# Line 341  PATTERN MODIFIERS Line 429  PATTERN MODIFIERS
429    
430         The  /I  modifier  requests  that pcretest output information about the         The  /I  modifier  requests  that pcretest output information about the
431         compiled pattern (whether it is anchored, has a fixed first  character,         compiled pattern (whether it is anchored, has a fixed first  character,
432         and so on). It does this by calling pcre[16]_fullinfo() after compiling         and  so  on). It does this by calling pcre[16|32]_fullinfo() after com-
433         a pattern. If the pattern is studied, the results of that are also out-         piling a pattern. If the pattern is studied, the results  of  that  are
434         put.         also output.
435    
436         The  /K modifier requests pcretest to show names from backtracking con-         The  /K modifier requests pcretest to show names from backtracking con-
437         trol verbs that are returned from calls to pcre[16]_exec().  It  causes         trol verbs that are  returned  from  calls  to  pcre[16|32]_exec().  It
438         pcretest  to  create a pcre[16]_extra block if one has not already been         causes  pcretest  to  create  a  pcre[16|32]_extra block if one has not
439         created by a call to pcre[16]_study(), and to set  the  PCRE_EXTRA_MARK         already been created by a call to pcre[16|32]_study(), and to  set  the
440         flag  and  the mark field within it, every time that pcre[16]_exec() is         PCRE_EXTRA_MARK  flag  and  the  mark  field within it, every time that
441         called. If the variable that the mark field points to is non-NULL for a         pcre[16|32]_exec() is called. If  the  variable  that  the  mark  field
442         match, non-match, or partial match, pcretest prints the string to which         points  to  is  non-NULL  for  a  match,  non-match,  or partial match,
443         it points. For a match, this is shown on a line by itself, tagged  with         pcretest prints the string to which it points. For  a  match,  this  is
444         "MK:". For a non-match it is added to the message.         shown  on  a  line  by itself, tagged with "MK:". For a non-match it is
445           added to the message.
446    
447         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
448         example,         example,
449    
450           /pattern/Lfr_FR           /pattern/Lfr_FR
451    
452         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,
453         pcre[16]_maketables()  is called to build a set of character tables for         pcre[16|32]_maketables() is called to build a set of  character  tables
454         the locale, and this is then passed to pcre[16]_compile() when  compil-         for  the  locale, and this is then passed to pcre[16|32]_compile() when
455         ing  the  regular  expression.  Without an /L (or /T) modifier, NULL is         compiling the regular expression. Without an /L (or /T) modifier,  NULL
456         passed as the tables pointer; that is, /L applies only to  the  expres-         is  passed  as  the  tables  pointer;  that  is, /L applies only to the
457         sion on which it appears.         expression on which it appears.
458    
459         The  /M  modifier  causes the size in bytes of the memory block used to         The /M modifier causes the size in bytes of the memory  block  used  to
460         hold the compiled pattern to be output. This does not include the  size         hold  the compiled pattern to be output. This does not include the size
461         of the pcre[16] block; it is just the actual compiled data. If the pat-         of the pcre[16|32] block; it is just the actual compiled data.  If  the
462         tern is successfully studied with  the  PCRE_STUDY_JIT_COMPILE  option,         pattern is successfully studied with the PCRE_STUDY_JIT_COMPILE option,
463         the size of the JIT compiled code is also output.         the size of the JIT compiled code is also output.
464    
465         If  the  /S  modifier  appears  once,  it causes pcre[16]_study() to be         The /S modifier causes  pcre[16|32]_study()  to  be  called  after  the
466         called after the expression has been compiled,  and  the  results  used         expression  has been compiled, and the results used when the expression
467         when  the  expression  is  matched.  If /S appears twice, it suppresses         is matched. There are a number of qualifying characters that may follow
468         studying, even if it was requested externally by the  -s  command  line         /S.  They may appear in any order.
469         option.  This  makes  it  possible to specify that certain patterns are  
470         always studied, and others are never studied, independently of -s. This         If  S is followed by an exclamation mark, pcre[16|32]_study() is called
471         feature  is  used  in the test files in a few cases where the output is         with the PCRE_STUDY_EXTRA_NEEDED option, causing it always to return  a
472         different when the pattern is studied.         pcre_extra block, even when studying discovers no useful information.
473    
474           If /S is followed by a second S character, it suppresses studying, even
475           if it was requested externally by the  -s  command  line  option.  This
476           makes  it possible to specify that certain patterns are always studied,
477           and others are never studied, independently of -s. This feature is used
478           in the test files in a few cases where the output is different when the
479           pattern is studied.
480    
481         If the /S modifier is immediately followed by a + character,  the  call         If the  /S  modifier  is  followed  by  a  +  character,  the  call  to
482         to  pcre[16]_study() is made with all the JIT study options, requesting         pcre[16|32]_study()  is made with all the JIT study options, requesting
483         just-in-time optimization support if it is available, for  both  normal         just-in-time optimization support if it is available, for  both  normal
484         and  partial matching. If you want to restrict the JIT compiling modes,         and  partial matching. If you want to restrict the JIT compiling modes,
485         you can follow /S+ with a digit in the range 1 to 7:         you can follow /S+ with a digit in the range 1 to 7:
# Line 403  PATTERN MODIFIERS Line 499  PATTERN MODIFIERS
499         given immediately after /S or /S+ because this will be misinterpreted.         given immediately after /S or /S+ because this will be misinterpreted.
500    
501         If JIT studying is successful, the compiled JIT code will automatically         If JIT studying is successful, the compiled JIT code will automatically
502         be used when pcre[16]_exec() is run, except when incompatible  run-time         be used when pcre[16|32]_exec() is run, except when  incompatible  run-
503         options are specified. For more details, see the pcrejit documentation.         time  options are specified. For more details, see the pcrejit documen-
504         See also the \J escape sequence below for a way of setting the size  of         tation. See also the \J escape sequence below for a way of setting  the
505         the JIT stack.         size of the JIT stack.
506    
507         The  /T  modifier  must be followed by a single digit. It causes a spe-         Finally,  if  /S  is  followed by a minus character, JIT compilation is
508         cific set of built-in character tables to be  passed  to  pcre[16]_com-         suppressed, even if it was requested externally by the -s command  line
509         pile().  It  is used in the standard PCRE tests to check behaviour with         option.  This makes it possible to specify that JIT is never to be used
510           for certain patterns.
511    
512           The /T modifier must be followed by a single digit. It  causes  a  spe-
513           cific set of built-in character tables to be passed to pcre[16|32]_com-
514           pile(). It is used in the standard PCRE tests to check  behaviour  with
515         different character tables. The digit specifies the tables as follows:         different character tables. The digit specifies the tables as follows:
516    
517           0   the default ASCII tables, as distributed in           0   the default ASCII tables, as distributed in
518                 pcre_chartables.c.dist                 pcre_chartables.c.dist
519           1   a set of tables defining ISO 8859 characters           1   a set of tables defining ISO 8859 characters
520    
521         In table 1, some characters whose codes are greater than 128 are  iden-         In  table 1, some characters whose codes are greater than 128 are iden-
522         tified as letters, digits, spaces, etc.         tified as letters, digits, spaces, etc.
523    
524     Using the POSIX wrapper API     Using the POSIX wrapper API
525    
526         The  /P modifier causes pcretest to call PCRE via the POSIX wrapper API         The /P modifier causes pcretest to call PCRE via the POSIX wrapper  API
527         rather than its native API. This supports only the 8-bit library.  When         rather  than its native API. This supports only the 8-bit library. When
528         /P  is set, the following modifiers set options for the regcomp() func-         /P is set, the following modifiers set options for the regcomp()  func-
529         tion:         tion:
530    
531           /i    REG_ICASE           /i    REG_ICASE
# Line 435  PATTERN MODIFIERS Line 536  PATTERN MODIFIERS
536           /W    REG_UCP        )   the POSIX standard           /W    REG_UCP        )   the POSIX standard
537           /8    REG_UTF8       )           /8    REG_UTF8       )
538    
539         The /+ modifier works as  described  above.  All  other  modifiers  are         The  /+  modifier  works  as  described  above. All other modifiers are
540         ignored.         ignored.
541    
542    
543  DATA LINES  DATA LINES
544    
545         Before  each data line is passed to pcre[16]_exec(), leading and trail-         Before each data line is  passed  to  pcre[16|32]_exec(),  leading  and
546         ing white space is removed, and it is then scanned for \ escapes.  Some         trailing  white space is removed, and it is then scanned for \ escapes.
547         of  these  are pretty esoteric features, intended for checking out some         Some of these are pretty esoteric features, intended for  checking  out
548         of the more complicated features of  PCRE.  If  you  are  just  testing         some  of the more complicated features of PCRE. If you are just testing
549         "ordinary"  regular  expressions, you probably don't need any of these.         "ordinary" regular expressions, you probably don't need any  of  these.
550         The following escapes are recognized:         The following escapes are recognized:
551    
552           \a         alarm (BEL, \x07)           \a         alarm (BEL, \x07)
# Line 459  DATA LINES Line 560  DATA LINES
560           \t         tab (\x09)           \t         tab (\x09)
561           \v         vertical tab (\x0b)           \v         vertical tab (\x0b)
562           \nnn       octal character (up to 3 octal digits); always           \nnn       octal character (up to 3 octal digits); always
563                        a byte unless > 255 in UTF-8 or 16-bit mode                        a byte unless > 255 in UTF-8 or 16-bit or 32-bit mode
564           \xhh       hexadecimal byte (up to 2 hex digits)           \xhh       hexadecimal byte (up to 2 hex digits)
565           \x{hh...}  hexadecimal character (any number of hex digits)           \x{hh...}  hexadecimal character (any number of hex digits)
566           \A         pass the PCRE_ANCHORED option to pcre[16]_exec()           \A         pass the PCRE_ANCHORED option to pcre[16|32]_exec()
567                        or pcre[16]_dfa_exec()                        or pcre[16|32]_dfa_exec()
568           \B         pass the PCRE_NOTBOL option to pcre[16]_exec()           \B         pass the PCRE_NOTBOL option to pcre[16|32]_exec()
569                        or pcre[16]_dfa_exec()                        or pcre[16|32]_dfa_exec()
570           \Cdd       call pcre[16]_copy_substring() for substring dd           \Cdd       call pcre[16|32]_copy_substring() for substring dd
571                        after a successful match (number less than 32)                        after a successful match (number less than 32)
572           \Cname     call pcre[16]_copy_named_substring() for substring           \Cname     call pcre[16|32]_copy_named_substring() for substring
573                        "name" after a successful match (name termin-                        "name" after a successful match (name termin-
574                        ated by next non alphanumeric character)                        ated by next non alphanumeric character)
575           \C+        show the current captured substrings at callout           \C+        show the current captured substrings at callout
# Line 480  DATA LINES Line 581  DATA LINES
581                        reached for the nth time                        reached for the nth time
582           \C*n       pass the number n (may be negative) as callout           \C*n       pass the number n (may be negative) as callout
583                        data; this is used as the callout return value                        data; this is used as the callout return value
584           \D         use the pcre[16]_dfa_exec() match function           \D         use the pcre[16|32]_dfa_exec() match function
585           \F         only shortest match for pcre[16]_dfa_exec()           \F         only shortest match for pcre[16|32]_dfa_exec()
586           \Gdd       call pcre[16]_get_substring() for substring dd           \Gdd       call pcre[16|32]_get_substring() for substring dd
587                        after a successful match (number less than 32)                        after a successful match (number less than 32)
588           \Gname     call pcre[16]_get_named_substring() for substring           \Gname     call pcre[16|32]_get_named_substring() for substring
589                        "name" after a successful match (name termin-                        "name" after a successful match (name termin-
590                        ated by next non-alphanumeric character)                        ated by next non-alphanumeric character)
591           \Jdd       set up a JIT stack of dd kilobytes maximum (any           \Jdd       set up a JIT stack of dd kilobytes maximum (any
592                        number of digits)                        number of digits)
593           \L         call pcre[16]_get_substringlist() after a           \L         call pcre[16|32]_get_substringlist() after a
594                        successful match                        successful match
595           \M         discover the minimum MATCH_LIMIT and           \M         discover the minimum MATCH_LIMIT and
596                        MATCH_LIMIT_RECURSION settings                        MATCH_LIMIT_RECURSION settings
597           \N         pass the PCRE_NOTEMPTY option to pcre[16]_exec()           \N         pass the PCRE_NOTEMPTY option to pcre[16|32]_exec()
598                        or pcre[16]_dfa_exec(); if used twice, pass the                        or pcre[16|32]_dfa_exec(); if used twice, pass the
599                        PCRE_NOTEMPTY_ATSTART option                        PCRE_NOTEMPTY_ATSTART option
600           \Odd       set the size of the output vector passed to           \Odd       set the size of the output vector passed to
601                        pcre[16]_exec() to dd (any number of digits)                        pcre[16|32]_exec() to dd (any number of digits)
602           \P         pass the PCRE_PARTIAL_SOFT option to pcre[16]_exec()           \P         pass the PCRE_PARTIAL_SOFT option to pcre[16|32]_exec()
603                        or pcre[16]_dfa_exec(); if used twice, pass the                        or pcre[16|32]_dfa_exec(); if used twice, pass the
604                        PCRE_PARTIAL_HARD option                        PCRE_PARTIAL_HARD option
605           \Qdd       set the PCRE_MATCH_LIMIT_RECURSION limit to dd           \Qdd       set the PCRE_MATCH_LIMIT_RECURSION limit to dd
606                        (any number of digits)                        (any number of digits)
607           \R         pass the PCRE_DFA_RESTART option to pcre[16]_dfa_exec()           \R         pass the PCRE_DFA_RESTART option to pcre[16|32]_dfa_exec()
608           \S         output details of memory get/free calls during matching           \S         output details of memory get/free calls during matching
609           \Y         pass the PCRE_NO_START_OPTIMIZE option to pcre[16]_exec()           \Y             pass     the    PCRE_NO_START_OPTIMIZE    option    to
610                        or pcre[16]_dfa_exec()         pcre[16|32]_exec()
611           \Z         pass the PCRE_NOTEOL option to pcre[16]_exec()                        or pcre[16|32]_dfa_exec()
612                        or pcre[16]_dfa_exec()           \Z         pass the PCRE_NOTEOL option to pcre[16|32]_exec()
613           \?         pass the PCRE_NO_UTF[8|16]_CHECK option to                        or pcre[16|32]_dfa_exec()
614                        pcre[16]_exec() or pcre[16]_dfa_exec()           \?         pass the PCRE_NO_UTF[8|16|32]_CHECK option to
615                          pcre[16|32]_exec() or pcre[16|32]_dfa_exec()
616           \>dd       start the match at offset dd (optional "-"; then           \>dd       start the match at offset dd (optional "-"; then
617                        any number of digits); this sets the startoffset                        any number of digits); this sets the startoffset
618                        argument for pcre[16]_exec() or pcre[16]_dfa_exec()                        argument        for        pcre[16|32]_exec()         or
619           \<cr>      pass the PCRE_NEWLINE_CR option to pcre[16]_exec()         pcre[16|32]_dfa_exec()
620                        or pcre[16]_dfa_exec()           \<cr>      pass the PCRE_NEWLINE_CR option to pcre[16|32]_exec()
621           \<lf>      pass the PCRE_NEWLINE_LF option to pcre[16]_exec()                        or pcre[16|32]_dfa_exec()
622                        or pcre[16]_dfa_exec()           \<lf>      pass the PCRE_NEWLINE_LF option to pcre[16|32]_exec()
623           \<crlf>    pass the PCRE_NEWLINE_CRLF option to pcre[16]_exec()                        or pcre[16|32]_dfa_exec()
624                        or pcre[16]_dfa_exec()           \<crlf>    pass the PCRE_NEWLINE_CRLF option to pcre[16|32]_exec()
625           \<anycrlf> pass the PCRE_NEWLINE_ANYCRLF option to pcre[16]_exec()                        or pcre[16|32]_dfa_exec()
626                        or pcre[16]_dfa_exec()           \<anycrlf> pass the PCRE_NEWLINE_ANYCRLF option to pcre[16|32]_exec()
627           \<any>     pass the PCRE_NEWLINE_ANY option to pcre[16]_exec()                        or pcre[16|32]_dfa_exec()
628                        or pcre[16]_dfa_exec()           \<any>     pass the PCRE_NEWLINE_ANY option to pcre[16|32]_exec()
629                          or pcre[16|32]_dfa_exec()
630         The use of \x{hh...} is not dependent on the use of the /8 modifier  on  
631         the  pattern. It is recognized always. There may be any number of hexa-         The  use of \x{hh...} is not dependent on the use of the /8 modifier on
632         decimal digits inside the braces; invalid  values  provoke  error  mes-         the pattern. It is recognized always. There may be any number of  hexa-
633           decimal  digits  inside  the  braces; invalid values provoke error mes-
634         sages.         sages.
635    
636         Note  that  \xhh  specifies one byte rather than one character in UTF-8         Note that \xhh specifies one byte rather than one  character  in  UTF-8
637         mode; this makes it possible to construct invalid UTF-8  sequences  for         mode;  this  makes it possible to construct invalid UTF-8 sequences for
638         testing  purposes.  On the other hand, \x{hh} is interpreted as a UTF-8         testing purposes. On the other hand, \x{hh} is interpreted as  a  UTF-8
639         character in UTF-8 mode, generating more than one byte if the value  is         character  in UTF-8 mode, generating more than one byte if the value is
640         greater  than  127.   When testing the 8-bit library not in UTF-8 mode,         greater than 127.  When testing the 8-bit library not  in  UTF-8  mode,
641         \x{hh} generates one byte for values less than 256, and causes an error         \x{hh} generates one byte for values less than 256, and causes an error
642         for greater values.         for greater values.
643    
644         In UTF-16 mode, all 4-digit \x{hhhh} values are accepted. This makes it         In UTF-16 mode, all 4-digit \x{hhhh} values are accepted. This makes it
645         possible to construct invalid UTF-16 sequences for testing purposes.         possible to construct invalid UTF-16 sequences for testing purposes.
646    
647         The escapes that specify line ending  sequences  are  literal  strings,         In  UTF-32  mode,  all  4- to 8-digit \x{...} values are accepted. This
648           makes it possible to construct invalid  UTF-32  sequences  for  testing
649           purposes.
650    
651           The  escapes  that  specify  line ending sequences are literal strings,
652         exactly as shown. No more than one newline setting should be present in         exactly as shown. No more than one newline setting should be present in
653         any data line.         any data line.
654    
655         A backslash followed by anything else just escapes the  anything  else.         A  backslash  followed by anything else just escapes the anything else.
656         If  the very last character is a backslash, it is ignored. This gives a         If the very last character is a backslash, it is ignored. This gives  a
657         way of passing an empty line as data, since a real  empty  line  termi-         way  of  passing  an empty line as data, since a real empty line termi-
658         nates the data input.         nates the data input.
659    
660         The  \J escape provides a way of setting the maximum stack size that is         The \J escape provides a way of setting the maximum stack size that  is
661         used by the just-in-time optimization code. It is ignored if JIT  opti-         used  by the just-in-time optimization code. It is ignored if JIT opti-
662         mization  is  not being used. Providing a stack that is larger than the         mization is not being used. Providing a stack that is larger  than  the
663         default 32K is necessary only for very complicated patterns.         default 32K is necessary only for very complicated patterns.
664    
665         If \M is present, pcretest calls pcre[16]_exec()  several  times,  with         If \M is present, pcretest calls pcre[16|32]_exec() several times, with
666         different values in the match_limit and match_limit_recursion fields of         different values in the match_limit and match_limit_recursion fields of
667         the pcre[16]_extra data structure, until it finds the  minimum  numbers         the  pcre[16|32]_extra  data structure, until it finds the minimum num-
668         for  each  parameter  that  allow  pcre[16]_exec()  to complete without         bers for each parameter that allow pcre[16|32]_exec() to complete with-
669         error. Because this is testing a specific feature of the normal  inter-         out  error.  Because  this  is testing a specific feature of the normal
670         pretive pcre[16]_exec() execution, the use of any JIT optimization that         interpretive pcre[16|32]_exec() execution, the use of any JIT optimiza-
671         might have been set up by the /S+ qualifier of -s+ option is disabled.         tion  that might have been set up by the /S+ qualifier of -s+ option is
672           disabled.
673    
674         The match_limit number is a measure of the amount of backtracking  that         The match_limit number is a measure of the amount of backtracking  that
675         takes  place,  and  checking it out can be instructive. For most simple         takes  place,  and  checking it out can be instructive. For most simple
# Line 574  DATA LINES Line 682  DATA LINES
682    
683         When  \O  is  used, the value specified may be higher or lower than the         When  \O  is  used, the value specified may be higher or lower than the
684         size set by the -O command line option (or defaulted to 45); \O applies         size set by the -O command line option (or defaulted to 45); \O applies
685         only to the call of pcre[16]_exec() for the line in which it appears.         only  to  the  call  of  pcre[16|32]_exec()  for  the  line in which it
686           appears.
687    
688         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-
689         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
690         effect  are  \B,  \N,  and  \Z,  causing  REG_NOTBOL, REG_NOTEMPTY, and         effect are \B,  \N,  and  \Z,  causing  REG_NOTBOL,  REG_NOTEMPTY,  and
691         REG_NOTEOL, respectively, to be passed to regexec().         REG_NOTEOL, respectively, to be passed to regexec().
692    
693    
694  THE ALTERNATIVE MATCHING FUNCTION  THE ALTERNATIVE MATCHING FUNCTION
695    
696         By  default,  pcretest  uses  the  standard  PCRE  matching   function,         By   default,  pcretest  uses  the  standard  PCRE  matching  function,
697         pcre[16]_exec() to match each data line. PCRE also supports an alterna-         pcre[16|32]_exec() to match each  data  line.  PCRE  also  supports  an
698         tive matching function, pcre[16]_dfa_test(), which operates in  a  dif-         alternative  matching  function, pcre[16|32]_dfa_test(), which operates
699         ferent  way, and has some restrictions. The differences between the two         in a different way, and has some restrictions. The differences  between
700         functions are described in the pcrematching documentation.         the two functions are described in the pcrematching documentation.
701    
702         If a data line contains the \D escape sequence, or if the command  line         If  a data line contains the \D escape sequence, or if the command line
703         contains  the  -dfa  option, the alternative matching function is used.         contains the -dfa option, the alternative matching  function  is  used.
704         This function finds all possible matches at a given point. If, however,         This function finds all possible matches at a given point. If, however,
705         the  \F escape sequence is present in the data line, it stops after the         the \F escape sequence is present in the data line, it stops after  the
706         first match is found. This is always the shortest possible match.         first match is found. This is always the shortest possible match.
707    
708    
709  DEFAULT OUTPUT FROM PCRETEST  DEFAULT OUTPUT FROM PCRETEST
710    
711         This section describes the output when the  normal  matching  function,         This  section  describes  the output when the normal matching function,
712         pcre[16]_exec(), is being used.         pcre[16|32]_exec(), is being used.
713    
714         When a match succeeds, pcretest outputs the list of captured substrings         When a match succeeds, pcretest outputs the list of captured substrings
715         that pcre[16]_exec() returns, starting with number  0  for  the  string         that  pcre[16|32]_exec() returns, starting with number 0 for the string
716         that  matched  the whole pattern. Otherwise, it outputs "No match" when         that matched the whole pattern. Otherwise, it outputs "No  match"  when
717         the return is PCRE_ERROR_NOMATCH, and "Partial match:" followed by  the         the  return is PCRE_ERROR_NOMATCH, and "Partial match:" followed by the
718         partially    matching    substring    when    pcre[16]_exec()   returns         partially   matching   substring   when   pcre[16|32]_exec()    returns
719         PCRE_ERROR_PARTIAL. (Note that this is the entire  substring  that  was         PCRE_ERROR_PARTIAL.  (Note  that  this is the entire substring that was
720         inspected  during  the  partial match; it may include characters before         inspected during the partial match; it may  include  characters  before
721         the actual match start if a lookbehind assertion, \K,  \b,  or  \B  was         the  actual  match  start  if a lookbehind assertion, \K, \b, or \B was
722         involved.)  For  any  other  return, pcretest outputs the PCRE negative         involved.) For any other return, pcretest  outputs  the  PCRE  negative
723         error number and a short descriptive phrase. If the error is  a  failed         error  number  and a short descriptive phrase. If the error is a failed
724         UTF  string check, the offset of the start of the failing character and         UTF string check, the offset of the start of the failing character  and
725         the reason code are also output, provided that the size of  the  output         the  reason  code are also output, provided that the size of the output
726         vector  is  at least two. Here is an example of an interactive pcretest         vector is at least two. Here is an example of an  interactive  pcretest
727         run.         run.
728    
729           $ pcretest           $ pcretest
# Line 628  DEFAULT OUTPUT FROM PCRETEST Line 737  DEFAULT OUTPUT FROM PCRETEST
737           No match           No match
738    
739         Unset capturing substrings that are not followed by one that is set are         Unset capturing substrings that are not followed by one that is set are
740         not  returned by pcre[16]_exec(), and are not shown by pcretest. In the         not returned by pcre[16|32]_exec(), and are not shown by  pcretest.  In
741         following example, there are two capturing  substrings,  but  when  the         the following example, there are two capturing substrings, but when the
742         first  data  line is matched, the second, unset substring is not shown.         first data line is matched, the second, unset substring is  not  shown.
743         An "internal" unset substring is shown as "<unset>", as for the  second         An  "internal" unset substring is shown as "<unset>", as for the second
744         data line.         data line.
745    
746             re> /(a)|(b)/             re> /(a)|(b)/
# Line 643  DEFAULT OUTPUT FROM PCRETEST Line 752  DEFAULT OUTPUT FROM PCRETEST
752            1: <unset>            1: <unset>
753            2: b            2: b
754    
755         If  the strings contain any non-printing characters, they are output as         If the strings contain any non-printing characters, they are output  as
756         \xhh escapes if the value is less than 256 and UTF  mode  is  not  set.         \xhh  escapes  if  the  value is less than 256 and UTF mode is not set.
757         Otherwise they are output as \x{hh...} escapes. See below for the defi-         Otherwise they are output as \x{hh...} escapes. See below for the defi-
758         nition of non-printing characters. If the pattern has the /+  modifier,         nition  of non-printing characters. If the pattern has the /+ modifier,
759         the  output  for substring 0 is followed by the the rest of the subject         the output for substring 0 is followed by the the rest of  the  subject
760         string, identified by "0+" like this:         string, identified by "0+" like this:
761    
762             re> /cat/+             re> /cat/+
# Line 655  DEFAULT OUTPUT FROM PCRETEST Line 764  DEFAULT OUTPUT FROM PCRETEST
764            0: cat            0: cat
765            0+ aract            0+ aract
766    
767         If the pattern has the /g or /G modifier,  the  results  of  successive         If  the  pattern  has  the /g or /G modifier, the results of successive
768         matching attempts are output in sequence, like this:         matching attempts are output in sequence, like this:
769    
770             re> /\Bi(\w\w)/g             re> /\Bi(\w\w)/g
# Line 667  DEFAULT OUTPUT FROM PCRETEST Line 776  DEFAULT OUTPUT FROM PCRETEST
776            0: ipp            0: ipp
777            1: pp            1: pp
778    
779         "No  match" is output only if the first match attempt fails. Here is an         "No match" is output only if the first match attempt fails. Here is  an
780         example of a failure message (the offset 4 that is specified by \>4  is         example  of a failure message (the offset 4 that is specified by \>4 is
781         past the end of the subject string):         past the end of the subject string):
782    
783             re> /xyz/             re> /xyz/
784           data> xyz\>4           data> xyz\>4
785           Error -24 (bad offset value)           Error -24 (bad offset value)
786    
787         If  any  of the sequences \C, \G, or \L are present in a data line that         If any of the sequences \C, \G, or \L are present in a data  line  that
788         is successfully matched, the substrings extracted  by  the  convenience         is  successfully  matched,  the substrings extracted by the convenience
789         functions are output with C, G, or L after the string number instead of         functions are output with C, G, or L after the string number instead of
790         a colon. This is in addition to the normal full list. The string length         a colon. This is in addition to the normal full list. The string length
791         (that  is,  the return from the extraction function) is given in paren-         (that is, the return from the extraction function) is given  in  paren-
792         theses after each string for \C and \G.         theses after each string for \C and \G.
793    
794         Note that whereas patterns can be continued over several lines (a plain         Note that whereas patterns can be continued over several lines (a plain
795         ">" prompt is used for continuations), data lines may not. However new-         ">" prompt is used for continuations), data lines may not. However new-
796         lines can be included in data by means of the \n escape (or  \r,  \r\n,         lines  can  be included in data by means of the \n escape (or \r, \r\n,
797         etc., depending on the newline sequence setting).         etc., depending on the newline sequence setting).
798    
799    
800  OUTPUT FROM THE ALTERNATIVE MATCHING FUNCTION  OUTPUT FROM THE ALTERNATIVE MATCHING FUNCTION
801    
802         When  the  alternative  matching function, pcre[16]_dfa_exec(), is used         When the alternative matching function, pcre[16|32]_dfa_exec(), is used
803         (by means of the \D escape sequence or the -dfa command  line  option),         (by  means  of the \D escape sequence or the -dfa command line option),
804         the  output  consists  of  a  list of all the matches that start at the         the output consists of a list of all the  matches  that  start  at  the
805         first point in the subject where there is at least one match. For exam-         first point in the subject where there is at least one match. For exam-
806         ple:         ple:
807    
# Line 702  OUTPUT FROM THE ALTERNATIVE MATCHING FUN Line 811  OUTPUT FROM THE ALTERNATIVE MATCHING FUN
811            1: tang            1: tang
812            2: tan            2: tan
813    
814         (Using  the  normal  matching function on this data finds only "tang".)         (Using the normal matching function on this data  finds  only  "tang".)
815         The longest matching string is always given first (and numbered  zero).         The  longest matching string is always given first (and numbered zero).
816         After a PCRE_ERROR_PARTIAL return, the output is "Partial match:", fol-         After a PCRE_ERROR_PARTIAL return, the output is "Partial match:", fol-
817         lowed by the partially matching  substring.  (Note  that  this  is  the         lowed  by  the  partially  matching  substring.  (Note that this is the
818         entire  substring  that  was inspected during the partial match; it may         entire substring that was inspected during the partial  match;  it  may
819         include characters before the actual match start if a lookbehind asser-         include characters before the actual match start if a lookbehind asser-
820         tion, \K, \b, or \B was involved.)         tion, \K, \b, or \B was involved.)
821    
# Line 722  OUTPUT FROM THE ALTERNATIVE MATCHING FUN Line 831  OUTPUT FROM THE ALTERNATIVE MATCHING FUN
831            1: tan            1: tan
832            0: tan            0: tan
833    
834         Since the matching function does not  support  substring  capture,  the         Since  the  matching  function  does not support substring capture, the
835         escape  sequences  that  are concerned with captured substrings are not         escape sequences that are concerned with captured  substrings  are  not
836         relevant.         relevant.
837    
838    
839  RESTARTING AFTER A PARTIAL MATCH  RESTARTING AFTER A PARTIAL MATCH
840    
841         When the alternative matching function has given the PCRE_ERROR_PARTIAL         When the alternative matching function has given the PCRE_ERROR_PARTIAL
842         return,  indicating that the subject partially matched the pattern, you         return, indicating that the subject partially matched the pattern,  you
843         can restart the match with additional subject data by means of  the  \R         can  restart  the match with additional subject data by means of the \R
844         escape sequence. For example:         escape sequence. For example:
845    
846             re> /^\d?\d(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)\d\d$/             re> /^\d?\d(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)\d\d$/
# Line 740  RESTARTING AFTER A PARTIAL MATCH Line 849  RESTARTING AFTER A PARTIAL MATCH
849           data> n05\R\D           data> n05\R\D
850            0: n05            0: n05
851    
852         For  further  information  about  partial matching, see the pcrepartial         For further information about partial  matching,  see  the  pcrepartial
853         documentation.         documentation.
854    
855    
856  CALLOUTS  CALLOUTS
857    
858         If the pattern contains any callout requests, pcretest's callout  func-         If  the pattern contains any callout requests, pcretest's callout func-
859         tion  is  called  during  matching. This works with both matching func-         tion is called during matching. This works  with  both  matching  func-
860         tions. By default, the called function displays the callout number, the         tions. By default, the called function displays the callout number, the
861         start  and  current  positions in the text at the callout time, and the         start and current positions in the text at the callout  time,  and  the
862         next pattern item to be tested. For example:         next pattern item to be tested. For example:
863    
864           --->pqrabcdef           --->pqrabcdef
865             0    ^  ^     \d             0    ^  ^     \d
866    
867         This output indicates that  callout  number  0  occurred  for  a  match         This  output  indicates  that  callout  number  0  occurred for a match
868         attempt  starting  at  the fourth character of the subject string, when         attempt starting at the fourth character of the  subject  string,  when
869         the pointer was at the seventh character of the data, and when the next         the pointer was at the seventh character of the data, and when the next
870         pattern  item  was  \d.  Just one circumflex is output if the start and         pattern item was \d. Just one circumflex is output  if  the  start  and
871         current positions are the same.         current positions are the same.
872    
873         Callouts numbered 255 are assumed to be automatic callouts, inserted as         Callouts numbered 255 are assumed to be automatic callouts, inserted as
874         a  result  of the /C pattern modifier. In this case, instead of showing         a result of the /C pattern modifier. In this case, instead  of  showing
875         the callout number, the offset in the pattern, preceded by a  plus,  is         the  callout  number, the offset in the pattern, preceded by a plus, is
876         output. For example:         output. For example:
877    
878             re> /\d?[A-E]\*/C             re> /\d?[A-E]\*/C
# Line 776  CALLOUTS Line 885  CALLOUTS
885            0: E*            0: E*
886    
887         If a pattern contains (*MARK) items, an additional line is output when-         If a pattern contains (*MARK) items, an additional line is output when-
888         ever a change of latest mark is passed to  the  callout  function.  For         ever  a  change  of  latest mark is passed to the callout function. For
889         example:         example:
890    
891             re> /a(*MARK:X)bc/C             re> /a(*MARK:X)bc/C
# Line 790  CALLOUTS Line 899  CALLOUTS
899           +12 ^  ^           +12 ^  ^
900            0: abc            0: abc
901    
902         The  mark  changes between matching "a" and "b", but stays the same for         The mark changes between matching "a" and "b", but stays the  same  for
903         the rest of the match, so nothing more is output. If, as  a  result  of         the  rest  of  the match, so nothing more is output. If, as a result of
904         backtracking,  the  mark  reverts to being unset, the text "<unset>" is         backtracking, the mark reverts to being unset, the  text  "<unset>"  is
905         output.         output.
906    
907         The callout function in pcretest returns zero (carry  on  matching)  by         The  callout  function  in pcretest returns zero (carry on matching) by
908         default,  but you can use a \C item in a data line (as described above)         default, but you can use a \C item in a data line (as described  above)
909         to change this and other parameters of the callout.         to change this and other parameters of the callout.
910    
911         Inserting callouts can be helpful when using pcretest to check  compli-         Inserting  callouts can be helpful when using pcretest to check compli-
912         cated  regular expressions. For further information about callouts, see         cated regular expressions. For further information about callouts,  see
913         the pcrecallout documentation.         the pcrecallout documentation.
914    
915    
916  NON-PRINTING CHARACTERS  NON-PRINTING CHARACTERS
917    
918         When pcretest is outputting text in the compiled version of a  pattern,         When  pcretest is outputting text in the compiled version of a pattern,
919         bytes  other  than 32-126 are always treated as non-printing characters         bytes other than 32-126 are always treated as  non-printing  characters
920         are are therefore shown as hex escapes.         are are therefore shown as hex escapes.
921    
922         When pcretest is outputting text that is a matched part  of  a  subject         When  pcretest  is  outputting text that is a matched part of a subject
923         string,  it behaves in the same way, unless a different locale has been         string, it behaves in the same way, unless a different locale has  been
924         set for the  pattern  (using  the  /L  modifier).  In  this  case,  the         set  for  the  pattern  (using  the  /L  modifier).  In  this case, the
925         isprint() function to distinguish printing and non-printing characters.         isprint() function to distinguish printing and non-printing characters.
926    
927    
928  SAVING AND RELOADING COMPILED PATTERNS  SAVING AND RELOADING COMPILED PATTERNS
929    
930         The  facilities  described  in  this section are not available when the         The facilities described in this section are  not  available  when  the
931         POSIX interface to PCRE is being used, that is,  when  the  /P  pattern         POSIX  interface  to  PCRE  is being used, that is, when the /P pattern
932         modifier is specified.         modifier is specified.
933    
934         When the POSIX interface is not in use, you can cause pcretest to write         When the POSIX interface is not in use, you can cause pcretest to write
935         a compiled pattern to a file, by following the modifiers with >  and  a         a  compiled  pattern to a file, by following the modifiers with > and a
936         file name.  For example:         file name.  For example:
937    
938           /pattern/im >/some/file           /pattern/im >/some/file
939    
940         See  the pcreprecompile documentation for a discussion about saving and         See the pcreprecompile documentation for a discussion about saving  and
941         re-using compiled patterns.  Note that if the pattern was  successfully         re-using  compiled patterns.  Note that if the pattern was successfully
942         studied with JIT optimization, the JIT data cannot be saved.         studied with JIT optimization, the JIT data cannot be saved.
943    
944         The  data  that  is  written  is  binary. The first eight bytes are the         The data that is written is binary.  The  first  eight  bytes  are  the
945         length of the compiled pattern data  followed  by  the  length  of  the         length  of  the  compiled  pattern  data  followed by the length of the
946         optional  study  data,  each  written as four bytes in big-endian order         optional study data, each written as four  bytes  in  big-endian  order
947         (most significant byte first). If there is no study  data  (either  the         (most  significant  byte  first). If there is no study data (either the
948         pattern was not studied, or studying did not return any data), the sec-         pattern was not studied, or studying did not return any data), the sec-
949         ond length is zero. The lengths are followed by an exact  copy  of  the         ond  length  is  zero. The lengths are followed by an exact copy of the
950         compiled  pattern.  If  there is additional study data, this (excluding         compiled pattern. If there is additional study  data,  this  (excluding
951         any JIT data) follows immediately after  the  compiled  pattern.  After         any  JIT  data)  follows  immediately after the compiled pattern. After
952         writing the file, pcretest expects to read a new pattern.         writing the file, pcretest expects to read a new pattern.
953    
954         A  saved  pattern  can  be reloaded into pcretest by specifying < and a         A saved pattern can be reloaded into pcretest by  specifying  <  and  a
955         file name instead of a pattern. The name of the file must not contain a         file name instead of a pattern. The name of the file must not contain a
956         < character, as otherwise pcretest will interpret the line as a pattern         < character, as otherwise pcretest will interpret the line as a pattern
957         delimited by < characters.  For example:         delimited by < characters.  For example:
# Line 851  SAVING AND RELOADING COMPILED PATTERNS Line 960  SAVING AND RELOADING COMPILED PATTERNS
960           Compiled pattern loaded from /some/file           Compiled pattern loaded from /some/file
961           No study data           No study data
962    
963         If the pattern was previously studied with the  JIT  optimization,  the         If  the  pattern  was previously studied with the JIT optimization, the
964         JIT  information cannot be saved and restored, and so is lost. When the         JIT information cannot be saved and restored, and so is lost. When  the
965         pattern has been loaded, pcretest proceeds to read data  lines  in  the         pattern  has  been  loaded, pcretest proceeds to read data lines in the
966         usual way.         usual way.
967    
968         You  can copy a file written by pcretest to a different host and reload         You can copy a file written by pcretest to a different host and  reload
969         it there, even if the new host has opposite endianness to  the  one  on         it  there,  even  if the new host has opposite endianness to the one on
970         which  the pattern was compiled. For example, you can compile on an i86         which the pattern was compiled. For example, you can compile on an  i86
971         machine and run on a SPARC machine. When a pattern  is  reloaded  on  a         machine  and  run  on  a SPARC machine. When a pattern is reloaded on a
972         host with different endianness, the confirmation message is changed to:         host with different endianness, the confirmation message is changed to:
973    
974           Compiled pattern (byte-inverted) loaded from /some/file           Compiled pattern (byte-inverted) loaded from /some/file
975    
976         The test suite contains some saved pre-compiled patterns with different         The test suite contains some saved pre-compiled patterns with different
977         endianness. These are reloaded using "<!" instead  of  just  "<".  This         endianness.  These  are  reloaded  using "<!" instead of just "<". This
978         suppresses the "(byte-inverted)" text so that the output is the same on         suppresses the "(byte-inverted)" text so that the output is the same on
979         all hosts. It also forces debugging output once the  pattern  has  been         all  hosts.  It  also forces debugging output once the pattern has been
980         reloaded.         reloaded.
981    
982         File  names  for  saving and reloading can be absolute or relative, but         File names for saving and reloading can be absolute  or  relative,  but
983         note that the shell facility of expanding a file name that starts  with         note  that the shell facility of expanding a file name that starts with
984         a tilde (~) is not available.         a tilde (~) is not available.
985    
986         The  ability to save and reload files in pcretest is intended for test-         The ability to save and reload files in pcretest is intended for  test-
987         ing and experimentation. It is not intended for production use  because         ing  and experimentation. It is not intended for production use because
988         only  a  single pattern can be written to a file. Furthermore, there is         only a single pattern can be written to a file. Furthermore,  there  is
989         no facility for supplying  custom  character  tables  for  use  with  a         no  facility  for  supplying  custom  character  tables  for use with a
990         reloaded  pattern.  If  the  original  pattern was compiled with custom         reloaded pattern. If the original  pattern  was  compiled  with  custom
991         tables, an attempt to match a subject string using a  reloaded  pattern         tables,  an  attempt to match a subject string using a reloaded pattern
992         is  likely to cause pcretest to crash.  Finally, if you attempt to load         is likely to cause pcretest to crash.  Finally, if you attempt to  load
993         a file that is not in the correct format, the result is undefined.         a file that is not in the correct format, the result is undefined.
994    
995    
996  SEE ALSO  SEE ALSO
997    
998         pcre(3), pcre16(3),  pcreapi(3),  pcrecallout(3),  pcrejit,  pcrematch-         pcre(3),  pcre16(3),  pcre32(3),  pcreapi(3),  pcrecallout(3), pcrejit,
999         ing(3), pcrepartial(d), pcrepattern(3), pcreprecompile(3).         pcrematching(3), pcrepartial(d), pcrepattern(3), pcreprecompile(3).
1000    
1001    
1002  AUTHOR  AUTHOR
# Line 899  AUTHOR Line 1008  AUTHOR
1008    
1009  REVISION  REVISION
1010    
1011         Last updated: 21 February 2012         Last updated: 10 September 2012
1012         Copyright (c) 1997-2012 University of Cambridge.         Copyright (c) 1997-2012 University of Cambridge.

Legend:
Removed from v.930  
changed lines
  Added in v.1194

  ViewVC Help
Powered by ViewVC 1.1.5