/[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 429 by ph10, Tue Sep 1 16:10:16 2009 UTC revision 1194 by ph10, Wed Oct 31 17:42:29 2012 UTC
# Line 7  NAME Line 7  NAME
7    
8  SYNOPSIS  SYNOPSIS
9    
10         pcretest [options] [source] [destination]         pcretest [options] [input file [output file]]
11    
12         pcretest  was written as a test program for the PCRE regular expression         pcretest  was written as a test program for the PCRE regular expression
13         library itself, but it can also be used for experimenting with  regular         library itself, but it can also be used for experimenting with  regular
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 documentation.         options, see the pcreapi , pcre16 and pcre32 documentation.
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    
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-
35           nal  one  supports  8-bit  character  strings, whereas the newer 16-bit
36           library supports  character  strings  encoded  in  16-bit  units.  From
37           release  8.32,  a  third  library  can  be  built, supporting character
38           strings encoded in 32-bit units.  The pcretest program can be  used  to
39           test all three libraries. However, it is itself still an 8-bit program,
40           reading 8-bit input and writing 8-bit output. When testing  the  16-bit
41           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|32]_xx below
46           mean "pcre_xx when using the 8-bit library or pcre16_xx when using  the
47           16-bit library".
48    
49    
50    COMMAND LINE OPTIONS
51    
52           -8        If  both the 8-bit library has been built, this option causes
53                     the 8-bit library to be used (which is the default);  if  the
54                     8-bit  library  has  not  been  built,  this option causes an
55                     error.
56    
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  OPTIONS         -b        Behave as if each pattern has the /B (show byte  code)  modi-
70                     fier; the internal form is output after compilation.
        -b        Behave as if each regex has the /B (show bytecode)  modifier;  
                  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.                   included, and then exit. All other options are ignored.
75    
76           -C option Output  information  about a specific build-time option, then
77                     exit. This functionality is intended for use in scripts  such
78                     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)
84                       newline    the default newline setting:
85                                    CR, LF, CRLF, ANYCRLF, or ANY
86    
87                     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
91                       pcre16     the 16-bit library was built
92                       pcre32     the 32-bit library was built
93                       pcre8      the 8-bit library was built
94                       ucp        Unicode property support is available
95                       utf         UTF-8  and/or  UTF-16  and/or UTF-32 support is
96                     available
97    
98         -d        Behave  as  if  each  regex  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
100                   output after compilation; -d is equivalent to -b -i.                   output after compilation; -d is equivalent to -b -i.
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_dfa_exec(),   to   be   used  instead  of  the  standard                   pcre[16|32]_dfa_exec(), to be used instead  of  the  standard
105                   pcre_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    
109         -i        Behave as if each regex  has  the  /I  modifier;  information         -i        Behave  as  if  each pattern has the /I modifier; information
110                   about the compiled pattern is given after compilation.                   about the compiled pattern is given after compilation.
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_exec() repeat-                   MATCH_LIMIT_RECURSION settings by calling  pcre[16|32]_exec()
115                   edly 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
118                   compiled.  This  is  equivalent  to adding /M to each regular                   compiled. This is equivalent to adding  /M  to  each  regular
119                   expression.  For  compatibility  with  earlier  versions   of                   expression. The size is given in bytes for both libraries.
                  pcretest, -s is a synonym for -m.  
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_exec() or pcre_dfa_exec() to be osize.  The                   when calling pcre[16|32]_exec() or pcre[16|32]_dfa_exec()  to
123                   default  value is 45, which is enough for 14 capturing subex-                   be  osize.  The  default  value is 45, which is enough for 14
124                   pressions  for  pcre_exec()  or  22  different  matches   for                   capturing subexpressions for pcre[16|32]_exec() or 22 differ-
125                   pcre_dfa_exec().  The vector size can be changed for individ-                   ent  matches for pcre[16|32]_dfa_exec().  The vector size can
126                   ual matching calls by including \O  in  the  data  line  (see                   be changed for individual matching calls by including  \O  in
127                   below).                   the data line (see below).
128    
129         -p        Behave  as if each regex has the /P modifier; the POSIX wrap-         -p        Behave  as  if  each  pattern  has the /P modifier; the POSIX
130                   per API is used to call PCRE. None of the other  options  has                   wrapper API is used to call PCRE. None of the  other  options
131                   any effect when -p is set.                   has  any  effect when -p is set. This option can be used only
132                     with the 8-bit library.
133    
134         -q        Do  not output the version number of pcretest at the start of         -q        Do not output the version number of pcretest at the start  of
135                   execution.                   execution.
136    
137         -S size   On Unix-like systems, set the size of the  runtime  stack  to         -S size   On  Unix-like  systems, set the size of the run-time stack to
138                   size megabytes.                   size megabytes.
139    
140         -t        Run  each  compile, study, and match many times with a timer,         -s or -s+ Behave as if each pattern  has  the  /S  modifier;  in  other
141                   and output resulting time per compile or match (in  millisec-                   words,  force each pattern to be studied. If -s+ is used, all
142                   onds).  Do  not set -m with -t, because you will then get the                   the JIT compile options are  passed  to  pcre[16|32]_study(),
143                   size output a zillion times, and  the  timing  will  be  dis-                   causing  just-in-time  optimization  to  be  set  up if it is
144                   torted.  You  can  control  the number of iterations that are                   available, for both full and partial matching.  Specific  JIT
145                   used for timing by following -t with a number (as a  separate                   compile options can be selected by following -s+ with a digit
146                     in the range 1 to 7, which selects the JIT compile  modes  as
147                     follows:
148    
149                       1  normal match only
150                       2  soft partial match only
151                       3  normal match and soft partial match
152                       4  hard partial match only
153                       6  soft and hard partial match
154                       7  all three modes (default)
155    
156                     If  -s++  is used instead of -s+ (with or without a following
157                     digit), the text "(JIT)" is added to the  first  output  line
158                     after a match or no match when JIT-compiled code was actually
159                     used.
160    
161                     Note that there are pattern options  that  can  override  -s,
162                     either specifying no studying at all, or suppressing JIT com-
163                     pilation.
164    
165                     If the /I or /D option is present on  a  pattern  (requesting
166                     output  about  the  compiled  pattern), information about the
167                     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                     line. This behaviour means that the output  from  tests  that
170                     are  run with and without -s should be identical, except when
171                     options that output information about the actual running of a
172                     match are set.
173    
174                     The  -M,  -t,  and  -tm options, which give information about
175                     resources used, are likely to produce different  output  with
176                     and  without  -s.  Output may also differ if the /C option is
177                     present on an individual pattern. This uses callouts to trace
178                     the  the  matching process, and this may be different between
179                     studied and non-studied patterns.  If  the  pattern  contains
180                     (*MARK)  items  there  may  also be differences, for the same
181                     reason. The -s command line option can be overridden for spe-
182                     cific  patterns that should never be studied (see the /S pat-
183                     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 83  OPTIONS Line 197  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.  Whitespace  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_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         The following table shows additional modifiers for setting PCRE options  
320         that do not correspond to anything in Perl:     Modifiers for other PCRE options
321    
322           The  following  table  shows additional modifiers for setting PCRE com-
323           pile-time options that do not correspond to anything in Perl:
324    
325             /8              PCRE_UTF8           ) when using the 8-bit
326             /?              PCRE_NO_UTF8_CHECK  )   library
327    
328             /8              PCRE_UTF16          ) when using the 16-bit
329             /?              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
# Line 164  PATTERN MODIFIERS Line 338  PATTERN MODIFIERS
338           /J              PCRE_DUPNAMES           /J              PCRE_DUPNAMES
339           /N              PCRE_NO_AUTO_CAPTURE           /N              PCRE_NO_AUTO_CAPTURE
340           /U              PCRE_UNGREEDY           /U              PCRE_UNGREEDY
341             /W              PCRE_UCP
342           /X              PCRE_EXTRA           /X              PCRE_EXTRA
343           /<JS>           PCRE_JAVASCRIPT_COMPAT           /Y              PCRE_NO_START_OPTIMIZE
344             /<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         Those specifying line ending sequences are literal  strings  as  shown,         The modifiers that are enclosed in angle brackets are  literal  strings
354         but  the  letters  can  be  in either case. This example sets multiline         as  shown,  including the angle brackets, but the letters within can be
355         matching with CRLF as the line ending sequence:         in either case.  This example sets multiline matching with CRLF as  the
356           line ending sequence:
357           /^abc/m<crlf>  
358             /^abc/m<CRLF>
359    
360           As  well  as  turning  on  the  PCRE_UTF8/16/32 option, the /8 modifier
361           causes all non-printing characters in  output  strings  to  be  printed
362           using the \x{hh...} notation. Otherwise, those less than 0x100 are out-
363           put in hex without the curly brackets.
364    
365         Details of the meanings of these PCRE options are given in the  pcreapi         Full details of the PCRE options are given in  the  pcreapi  documenta-
366         documentation.         tion.
367    
368     Finding all matches in a string     Finding all matches in a string
369    
# Line 189  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_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_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 and  PCRE_ANCHORED         empty string, the next call is done with the PCRE_NOTEMPTY_ATSTART  and
382         flags  set in order to search for another, non-empty, match at the same         PCRE_ANCHORED  flags  set  in  order  to search for another, non-empty,
383         point.  If this second match fails, the start  offset  is  advanced  by         match at the same point. If this second match fails, the  start  offset
384         one,  and  the normal match is retried. This imitates the way Perl han-         is  advanced,  and  the  normal match is retried. This imitates the way
385         dles such cases when using the /g modifier or the split() function.         Perl handles such cases when using the /g modifier or the split() func-
386           tion.  Normally,  the start offset is advanced by one character, but if
387           the newline convention recognizes CRLF as a newline,  and  the  current
388           character is CR followed by LF, an advance of two is used.
389    
390     Other modifiers     Other modifiers
391    
392         There are yet more modifiers for controlling the way pcretest operates.         There are yet more modifiers for controlling the way pcretest operates.
393    
394         The /+ modifier requests that as well as outputting the substring  that         The  /+ modifier requests that as well as outputting the substring that
395         matched  the  entire  pattern,  pcretest  should in addition output the         matched the entire pattern, pcretest  should  in  addition  output  the
396         remainder of the subject string. This is useful  for  tests  where  the         remainder  of  the  subject  string. This is useful for tests where the
397         subject contains multiple copies of the same substring.         subject contains multiple copies of the same substring. If the +  modi-
398           fier  appears  twice, the same action is taken for captured substrings.
399           In each case the remainder is output on the following line with a  plus
400           character  following  the  capture number. Note that this modifier must
401           not immediately follow the /S modifier because /S+ and /S++ have  other
402           meanings.
403    
404           The  /=  modifier  requests  that  the values of all potential captured
405           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
407           return code from pcre[16|32]_exec()). Values in the offsets vector cor-
408           responding  to higher numbers should be set to -1, and these are output
409           as "<unset>". This modifier gives a way of checking that this  is  hap-
410           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 byte code after compilation.  Nor-         put a representation of the compiled code after  compilation.  Normally
414         mally  this  information contains length and offset values; however, if         this  information  contains length and offset values; however, if /Z is
415         /Z is also present, this data is replaced by spaces. This is a  special         also present, this data is replaced by spaces. This is a  special  fea-
416         feature for use in the automatic test scripts; it ensures that the same         ture  for  use  in the automatic test scripts; it ensures that the same
417         output is generated for different internal link sizes.         output is generated for different internal link sizes.
418    
419           The /D modifier is a PCRE debugging feature, and is equivalent to  /BI,
420           that is, both the /B and the /I modifiers.
421    
422           The  /F  modifier  causes pcretest to flip the byte order of the 2-byte
423           and 4-byte fields in the compiled pattern. This facility is for testing
424           the  feature  in PCRE that allows it to execute patterns that were com-
425           piled on a host with a different endianness. This feature is not avail-
426           able  when the POSIX interface to PCRE is being used, that is, when the
427           /P pattern modifier is specified. See also the section about saving and
428           reloading compiled patterns below.
429    
430           The  /I  modifier  requests  that pcretest output information about the
431           compiled pattern (whether it is anchored, has a fixed first  character,
432           and  so  on). It does this by calling pcre[16|32]_fullinfo() after com-
433           piling a pattern. If the pattern is studied, the results  of  that  are
434           also output.
435    
436           The  /K modifier requests pcretest to show names from backtracking con-
437           trol verbs that are  returned  from  calls  to  pcre[16|32]_exec().  It
438           causes  pcretest  to  create  a  pcre[16|32]_extra block if one has not
439           already been created by a call to pcre[16|32]_study(), and to  set  the
440           PCRE_EXTRA_MARK  flag  and  the  mark  field within it, every time that
441           pcre[16|32]_exec() is called. If  the  variable  that  the  mark  field
442           points  to  is  non-NULL  for  a  match,  non-match,  or partial match,
443           pcretest prints the string to which it points. For  a  match,  this  is
444           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_maketables() is called to build a set of character tables for  the         pcre[16|32]_maketables() is called to build a set of  character  tables
454         locale,  and  this  is then passed to pcre_compile() when compiling the         for  the  locale, and this is then passed to pcre[16|32]_compile() when
455         regular expression. Without an /L  modifier,  NULL  is  passed  as  the         compiling the regular expression. Without an /L (or /T) modifier,  NULL
456         tables  pointer; that is, /L applies only to the expression on which it         is  passed  as  the  tables  pointer;  that  is, /L applies only to the
457         appears.         expression on which it appears.
458    
459           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
461           of the pcre[16|32] block; it is just the actual compiled data.  If  the
462           pattern is successfully studied with the PCRE_STUDY_JIT_COMPILE option,
463           the size of the JIT compiled code is also output.
464    
465           The /S modifier causes  pcre[16|32]_study()  to  be  called  after  the
466           expression  has been compiled, and the results used when the expression
467           is matched. There are a number of qualifying characters that may follow
468           /S.  They may appear in any order.
469    
470           If  S is followed by an exclamation mark, pcre[16|32]_study() is called
471           with the PCRE_STUDY_EXTRA_NEEDED option, causing it always to return  a
472           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  followed  by  a  +  character,  the  call  to
482           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
484           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:
486    
487             1  normal match only
488             2  soft partial match only
489             3  normal match and soft partial match
490             4  hard partial match only
491             6  soft and hard partial match
492             7  all three modes (default)
493    
494           If /S++ is used instead of /S+ (with or without a following digit), the
495           text  "(JIT)"  is  added  to  the first output line after a match or no
496           match when JIT-compiled code was actually used.
497    
498           Note that there is also an independent /+  modifier;  it  must  not  be
499           given immediately after /S or /S+ because this will be misinterpreted.
500    
501           If JIT studying is successful, the compiled JIT code will automatically
502           be used when pcre[16|32]_exec() is run, except when  incompatible  run-
503           time  options are specified. For more details, see the pcrejit documen-
504           tation. See also the \J escape sequence below for a way of setting  the
505           size of the JIT stack.
506    
507           Finally,  if  /S  is  followed by a minus character, JIT compilation is
508           suppressed, even if it was requested externally by the -s command  line
509           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:
516    
517             0   the default ASCII tables, as distributed in
518                   pcre_chartables.c.dist
519             1   a set of tables defining ISO 8859 characters
520    
521           In  table 1, some characters whose codes are greater than 128 are iden-
522           tified as letters, digits, spaces, etc.
523    
524       Using the POSIX wrapper API
525    
526           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
528           /P is set, the following modifiers set options for the regcomp()  func-
529           tion:
530    
531             /i    REG_ICASE
532             /m    REG_NEWLINE
533             /N    REG_NOSUB
534             /s    REG_DOTALL     )
535             /U    REG_UNGREEDY   ) These options are not part of
536             /W    REG_UCP        )   the POSIX standard
537             /8    REG_UTF8       )
538    
539         The /I modifier requests that pcretest  output  information  about  the         The  /+  modifier  works  as  described  above. All other modifiers are
540         compiled  pattern (whether it is anchored, has a fixed first character,         ignored.
        and so on). It does this by calling pcre_fullinfo() after  compiling  a  
        pattern.  If  the pattern is studied, the results of that are also out-  
        put.  
   
        The /D modifier is a PCRE debugging feature, and is equivalent to  /BI,  
        that is, both the /B and the /I modifiers.  
   
        The /F modifier causes pcretest to flip the byte order of the fields in  
        the compiled pattern that  contain  2-byte  and  4-byte  numbers.  This  
        facility  is  for testing the feature in PCRE that allows it to execute  
        patterns that were compiled on a host with a different endianness. This  
        feature  is  not  available  when  the POSIX interface to PCRE is being  
        used, that is, when the /P pattern modifier is specified. See also  the  
        section about saving and reloading compiled patterns below.  
   
        The  /S  modifier causes pcre_study() to be called after the expression  
        has been compiled, and the results used when the expression is matched.  
   
        The /M modifier causes the size of memory block used to hold  the  com-  
        piled pattern to be output.  
   
        The  /P modifier causes pcretest to call PCRE via the POSIX wrapper API  
        rather than its native API. When this  is  done,  all  other  modifiers  
        except  /i,  /m, and /+ are ignored. REG_ICASE is set if /i is present,  
        and REG_NEWLINE is set if /m is present. The  wrapper  functions  force  
        PCRE_DOLLAR_ENDONLY always, and PCRE_DOTALL unless REG_NEWLINE is set.  
   
        The  /8 modifier causes pcretest to call PCRE with the PCRE_UTF8 option  
        set. This turns on support for UTF-8 character handling in  PCRE,  pro-  
        vided  that  it  was  compiled with this support enabled. This modifier  
        also causes any non-printing characters in output strings to be printed  
        using the \x{hh...} notation if they are valid UTF-8 sequences.  
   
        If  the  /?  modifier  is  used  with  /8,  it  causes pcretest to call  
        pcre_compile() with the  PCRE_NO_UTF8_CHECK  option,  to  suppress  the  
        checking of the string for UTF-8 validity.  
541    
542    
543  DATA LINES  DATA LINES
544    
545         Before  each  data  line is passed to pcre_exec(), leading and trailing         Before each data line is  passed  to  pcre[16|32]_exec(),  leading  and
546         whitespace is removed, and it is then scanned for \  escapes.  Some  of         trailing  white space is removed, and it is then scanned for \ escapes.
547         these  are  pretty esoteric features, intended for checking out some of         Some of these are pretty esoteric features, intended for  checking  out
548         the more complicated features of PCRE. If you are just  testing  "ordi-         some  of the more complicated features of PCRE. If you are just testing
549         nary"  regular  expressions,  you probably don't need any of these. The         "ordinary" regular expressions, you probably don't need any  of  these.
550         following escapes are recognized:         The following escapes are recognized:
551    
552           \a         alarm (BEL, \x07)           \a         alarm (BEL, \x07)
553           \b         backspace (\x08)           \b         backspace (\x08)
554           \e         escape (\x27)           \e         escape (\x27)
555           \f         formfeed (\x0c)           \f         form feed (\x0c)
556           \n         newline (\x0a)           \n         newline (\x0a)
557           \qdd       set the PCRE_MATCH_LIMIT limit to dd           \qdd       set the PCRE_MATCH_LIMIT limit to dd
558                        (any number of digits)                        (any number of digits)
559           \r         carriage return (\x0d)           \r         carriage return (\x0d)
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)           \nnn       octal character (up to 3 octal digits); always
563           \xhh       hexadecimal character (up to 2 hex digits)                        a byte unless > 255 in UTF-8 or 16-bit or 32-bit mode
564           \x{hh...}  hexadecimal character, any number of digits           \xhh       hexadecimal byte (up to 2 hex digits)
565                        in UTF-8 mode           \x{hh...}  hexadecimal character (any number of hex digits)
566           \A         pass the PCRE_ANCHORED option to pcre_exec()           \A         pass the PCRE_ANCHORED option to pcre[16|32]_exec()
567                        or pcre_dfa_exec()                        or pcre[16|32]_dfa_exec()
568           \B         pass the PCRE_NOTBOL option to pcre_exec()           \B         pass the PCRE_NOTBOL option to pcre[16|32]_exec()
569                        or pcre_dfa_exec()                        or pcre[16|32]_dfa_exec()
570           \Cdd       call pcre_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_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 311  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_dfa_exec() match function           \D         use the pcre[16|32]_dfa_exec() match function
585           \F         only shortest match for pcre_dfa_exec()           \F         only shortest match for pcre[16|32]_dfa_exec()
586           \Gdd       call pcre_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_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           \L         call pcre_get_substringlist() after a           \Jdd       set up a JIT stack of dd kilobytes maximum (any
592                          number of digits)
593             \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_exec()           \N         pass the PCRE_NOTEMPTY option to pcre[16|32]_exec()
598                        or pcre_dfa_exec()                        or pcre[16|32]_dfa_exec(); if used twice, pass the
599                          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_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_exec()           \P         pass the PCRE_PARTIAL_SOFT option to pcre[16|32]_exec()
603                        or pcre_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_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           \Z         pass the PCRE_NOTEOL option to pcre_exec()           \Y             pass     the    PCRE_NO_START_OPTIMIZE    option    to
610                        or pcre_dfa_exec()         pcre[16|32]_exec()
611           \?         pass the PCRE_NO_UTF8_CHECK option to                        or pcre[16|32]_dfa_exec()
612                        pcre_exec() or pcre_dfa_exec()           \Z         pass the PCRE_NOTEOL option to pcre[16|32]_exec()
613           \>dd       start the match at offset dd (any number of digits);                        or pcre[16|32]_dfa_exec()
614                        this sets the startoffset argument for pcre_exec()           \?         pass the PCRE_NO_UTF[8|16|32]_CHECK option to
615                        or pcre_dfa_exec()                        pcre[16|32]_exec() or pcre[16|32]_dfa_exec()
616           \<cr>      pass the PCRE_NEWLINE_CR option to pcre_exec()           \>dd       start the match at offset dd (optional "-"; then
617                        or pcre_dfa_exec()                        any number of digits); this sets the startoffset
618           \<lf>      pass the PCRE_NEWLINE_LF option to pcre_exec()                        argument        for        pcre[16|32]_exec()         or
619                        or pcre_dfa_exec()         pcre[16|32]_dfa_exec()
620           \<crlf>    pass the PCRE_NEWLINE_CRLF option to pcre_exec()           \<cr>      pass the PCRE_NEWLINE_CR option to pcre[16|32]_exec()
621                        or pcre_dfa_exec()                        or pcre[16|32]_dfa_exec()
622           \<anycrlf> pass the PCRE_NEWLINE_ANYCRLF option to pcre_exec()           \<lf>      pass the PCRE_NEWLINE_LF option to pcre[16|32]_exec()
623                        or pcre_dfa_exec()                        or pcre[16|32]_dfa_exec()
624           \<any>     pass the PCRE_NEWLINE_ANY option to pcre_exec()           \<crlf>    pass the PCRE_NEWLINE_CRLF option to pcre[16|32]_exec()
625                        or pcre_dfa_exec()                        or pcre[16|32]_dfa_exec()
626             \<anycrlf> pass the PCRE_NEWLINE_ANYCRLF option to pcre[16|32]_exec()
627                          or pcre[16|32]_dfa_exec()
628             \<any>     pass the PCRE_NEWLINE_ANY option to pcre[16|32]_exec()
629                          or pcre[16|32]_dfa_exec()
630    
631           The  use of \x{hh...} is not dependent on the use of the /8 modifier on
632           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.
635    
636           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
638           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
640           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
642           for greater values.
643    
644           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.
646    
647           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,         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         If  \M  is present, pcretest calls pcre_exec() several times, with dif-         The \J escape provides a way of setting the maximum stack size that  is
661         ferent values in the match_limit and  match_limit_recursion  fields  of         used  by the just-in-time optimization code. It is ignored if JIT opti-
662         the  pcre_extra  data structure, until it finds the minimum numbers for         mization is not being used. Providing a stack that is larger  than  the
663         each parameter that allow pcre_exec() to complete. The match_limit num-         default 32K is necessary only for very complicated patterns.
664         ber  is  a  measure of the amount of backtracking that takes place, and  
665         checking it out can be instructive. For most simple matches, the number         If \M is present, pcretest calls pcre[16|32]_exec() several times, with
666         is  quite  small,  but for patterns with very large numbers of matching         different values in the match_limit and match_limit_recursion fields of
667         possibilities, it can become large very quickly with increasing  length         the  pcre[16|32]_extra  data structure, until it finds the minimum num-
668         of subject string. The match_limit_recursion number is a measure of how         bers for each parameter that allow pcre[16|32]_exec() to complete with-
669         much stack (or, if PCRE is compiled with  NO_RECURSE,  how  much  heap)         out  error.  Because  this  is testing a specific feature of the normal
670         memory is needed to complete the match attempt.         interpretive pcre[16|32]_exec() execution, the use of any JIT optimiza-
671           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
675           takes  place,  and  checking it out can be instructive. For most simple
676           matches, the number is quite small, but for patterns  with  very  large
677           numbers  of  matching  possibilities,  it can become large very quickly
678           with increasing length of  subject  string.  The  match_limit_recursion
679           number  is  a  measure  of how much stack (or, if PCRE is compiled with
680           NO_RECURSE, how much heap) memory  is  needed  to  complete  the  match
681           attempt.
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_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 and \Z, causing REG_NOTBOL and REG_NOTEOL, respectively,         effect are \B,  \N,  and  \Z,  causing  REG_NOTBOL,  REG_NOTEMPTY,  and
691         to be passed to regexec().         REG_NOTEOL, respectively, to be passed to regexec().
   
        The use of \x{hh...} to represent UTF-8 characters is not dependent  on  
        the  use  of  the  /8 modifier on the pattern. It is recognized always.  
        There may be any number of hexadecimal digits inside  the  braces.  The  
        result  is  from  one  to  six bytes, encoded according to the original  
        UTF-8 rules of RFC 2279. This allows for  values  in  the  range  0  to  
        0x7FFFFFFF.  Note  that not all of those are valid Unicode code points,  
        or indeed valid UTF-8 characters according to the later  rules  in  RFC  
        3629.  
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_exec() to match each data line. From release 6.0, PCRE supports an         pcre[16|32]_exec() to match each  data  line.  PCRE  also  supports  an
698         alternative  matching  function,  pcre_dfa_test(),  which operates in a         alternative  matching  function, pcre[16|32]_dfa_test(), which operates
699         different way, and has some restrictions. The differences  between  the         in a different way, and has some restrictions. The differences  between
700         two 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  called.         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.
# Line 409  THE ALTERNATIVE MATCHING FUNCTION Line 709  THE ALTERNATIVE MATCHING FUNCTION
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_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_exec()  returns,  starting with number 0 for the string that         that  pcre[16|32]_exec() returns, starting with number 0 for the string
716         matched the whole pattern. Otherwise, it outputs "No match" or "Partial         that matched the whole pattern. Otherwise, it outputs "No  match"  when
717         match:"  followed  by the partially matching substring when pcre_exec()         the  return is PCRE_ERROR_NOMATCH, and "Partial match:" followed by the
718         returns PCRE_ERROR_NOMATCH  or  PCRE_ERROR_PARTIAL,  respectively,  and         partially   matching   substring   when   pcre[16|32]_exec()    returns
719         otherwise  the  PCRE  negative  error  number. Here is an example of an         PCRE_ERROR_PARTIAL.  (Note  that  this is the entire substring that was
720         interactive pcretest run.         inspected during the partial match; it may  include  characters  before
721           the  actual  match  start  if a lookbehind assertion, \K, \b, or \B was
722           involved.) For any other return, pcretest  outputs  the  PCRE  negative
723           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
725           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
727           run.
728    
729           $ pcretest           $ pcretest
730           PCRE version 7.0 30-Nov-2006           PCRE version 8.13 2011-04-30
731    
732             re> /^abc(\d+)/             re> /^abc(\d+)/
733           data> abc123           data> abc123
# Line 429  DEFAULT OUTPUT FROM PCRETEST Line 736  DEFAULT OUTPUT FROM PCRETEST
736           data> xyz           data> xyz
737           No match           No match
738    
739         Note that unset capturing substrings that are not followed by one  that         Unset capturing substrings that are not followed by one that is set are
740         is  set are not returned by pcre_exec(), and are not shown by pcretest.         not returned by pcre[16|32]_exec(), and are not shown by  pcretest.  In
741         In the following example, there are two capturing substrings, but  when         the following example, there are two capturing substrings, but when the
742         the  first  data  line  is  matched, the second, unset substring is not         first data line is matched, the second, unset substring is  not  shown.
743         shown. An "internal" unset substring is shown as "<unset>", as for  the         An  "internal" unset substring is shown as "<unset>", as for the second
744         second data line.         data line.
745    
746             re> /(a)|(b)/             re> /(a)|(b)/
747           data> a           data> a
# Line 445  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         \0x escapes, or as \x{...} escapes if the /8 modifier  was  present  on         \xhh  escapes  if  the  value is less than 256 and UTF mode is not set.
757         the  pattern.  See below for the definition of non-printing characters.         Otherwise they are output as \x{hh...} escapes. See below for the defi-
758         If the pattern has the /+ modifier, the output for substring 0 is  fol-         nition  of non-printing characters. If the pattern has the /+ modifier,
759         lowed  by  the  the rest of the subject string, identified by "0+" like         the output for substring 0 is followed by the the rest of  the  subject
760         this:         string, identified by "0+" like this:
761    
762             re> /cat/+             re> /cat/+
763           data> cataract           data> cataract
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 469  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.         "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
781           past the end of the subject string):
782    
783               re> /xyz/
784             data> xyz\>4
785             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_dfa_exec(), is used (by         When the alternative matching function, pcre[16|32]_dfa_exec(), is used
803         means of the \D escape sequence or the -dfa command line  option),  the         (by  means  of the \D escape sequence or the -dfa command line option),
804         output  consists  of  a list of all the matches that start at the first         the output consists of a list of all the  matches  that  start  at  the
805         point in the subject where there is at least one match. For example:         first point in the subject where there is at least one match. For exam-
806           ple:
807    
808             re> /(tang|tangerine|tan)/             re> /(tang|tangerine|tan)/
809           data> yellow tangerine\D           data> yellow tangerine\D
# Line 500  OUTPUT FROM THE ALTERNATIVE MATCHING FUN Line 814  OUTPUT FROM THE ALTERNATIVE MATCHING FUN
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.         lowed  by  the  partially  matching  substring.  (Note that this is the
818           entire substring that was inspected during the partial  match;  it  may
819           include characters before the actual match start if a lookbehind asser-
820           tion, \K, \b, or \B was involved.)
821    
822         If /g is present on the pattern, the search for further matches resumes         If /g is present on the pattern, the search for further matches resumes
823         at the end of the longest match. For example:         at the end of the longest match. For example:
# Line 514  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 532  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, the output         next pattern item to be tested. For example:
863    
864           --->pqrabcdef           --->pqrabcdef
865             0    ^  ^     \d             0    ^  ^     \d
866    
867         indicates that callout number 0 occurred for a match  attempt  starting         This  output  indicates  that  callout  number  0  occurred for a match
868         at  the fourth character of the subject string, when the pointer was at         attempt starting at the fourth character of the  subject  string,  when
869         the seventh character of the data, and when the next pattern  item  was         the pointer was at the seventh character of the data, and when the next
870         \d.  Just  one  circumflex is output if the start and current positions         pattern item was \d. Just one circumflex is output  if  the  start  and
871         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 567  CALLOUTS Line 884  CALLOUTS
884           +10 ^ ^           +10 ^ ^
885            0: E*            0: E*
886    
887           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
889           example:
890    
891               re> /a(*MARK:X)bc/C
892             data> abc
893             --->abc
894              +0 ^       a
895              +1 ^^      (*MARK:X)
896             +10 ^^      b
897             Latest Mark: X
898             +11 ^ ^     c
899             +12 ^  ^
900              0: abc
901    
902           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
904           backtracking, the mark reverts to being unset, the  text  "<unset>"  is
905           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.         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
# Line 591  NON-PRINTING CHARACTERS Line 928  NON-PRINTING CHARACTERS
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 inteface to PCRE is being used, that is, when the /P pattern mod-         POSIX  interface  to  PCRE  is being used, that is, when the /P pattern
932         ifier 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
# Line 601  SAVING AND RELOADING COMPILED PATTERNS Line 938  SAVING AND RELOADING COMPILED PATTERNS
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.         re-using  compiled patterns.  Note that if the pattern was successfully
942           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 follows imme-         compiled pattern. If there is additional study  data,  this  (excluding
951         diately after the compiled pattern. After writing  the  file,  pcretest         any  JIT  data)  follows  immediately after the compiled pattern. After
952         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 specifing < and a file         A saved pattern can be reloaded into pcretest by  specifying  <  and  a
955         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:
958    
959            re> </some/file            re> </some/file
960           Compiled regex loaded from /some/file           Compiled pattern loaded from /some/file
961           No study data           No study data
962    
963         When the pattern has been loaded, pcretest proceeds to read data  lines         If  the  pattern  was previously studied with the JIT optimization, the
964         in the usual way.         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
966         You  can copy a file written by pcretest to a different host and reload         usual way.
967         it there, even if the new host has opposite endianness to  the  one  on  
968         which  the pattern was compiled. For example, you can compile on an i86         You can copy a file written by pcretest to a different host and  reload
969         machine and run on a SPARC machine.         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
971           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:
973    
974             Compiled pattern (byte-inverted) loaded from /some/file
975    
976           The test suite contains some saved pre-compiled patterns with different
977           endianness.  These  are  reloaded  using "<!" instead of just "<". This
978           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
980           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
# Line 646  SAVING AND RELOADING COMPILED PATTERNS Line 995  SAVING AND RELOADING COMPILED PATTERNS
995    
996  SEE ALSO  SEE ALSO
997    
998         pcre(3),  pcreapi(3),  pcrecallout(3), pcrematching(3), pcrepartial(d),         pcre(3),  pcre16(3),  pcre32(3),  pcreapi(3),  pcrecallout(3), pcrejit,
999         pcrepattern(3), pcreprecompile(3).         pcrematching(3), pcrepartial(d), pcrepattern(3), pcreprecompile(3).
1000    
1001    
1002  AUTHOR  AUTHOR
# Line 659  AUTHOR Line 1008  AUTHOR
1008    
1009  REVISION  REVISION
1010    
1011         Last updated: 29 August 2009         Last updated: 10 September 2012
1012         Copyright (c) 1997-2009 University of Cambridge.         Copyright (c) 1997-2012 University of Cambridge.

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

  ViewVC Help
Powered by ViewVC 1.1.5