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

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

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

revision 231 by ph10, Tue Sep 11 11:15:33 2007 UTC revision 289 by ph10, Sun Dec 23 12:17:20 2007 UTC
# Line 271  NAME Line 271  NAME
271  PCRE BUILD-TIME OPTIONS  PCRE BUILD-TIME OPTIONS
272    
273         This  document  describes  the  optional  features  of PCRE that can be         This  document  describes  the  optional  features  of PCRE that can be
274         selected when the library is compiled. They are all selected, or  dese-         selected when the library is compiled. It assumes use of the  configure
275         lected, by providing options to the configure script that is run before         script,  where the optional features are selected or deselected by pro-
276         the make command. The complete list of  options  for  configure  (which         viding options to configure before running the make  command.  However,
277         includes  the  standard  ones such as the selection of the installation         the  same  options  can be selected in both Unix-like and non-Unix-like
278         directory) can be obtained by running         environments using the GUI facility of  CMakeSetup  if  you  are  using
279           CMake instead of configure to build PCRE.
280    
281           The complete list of options for configure (which includes the standard
282           ones such as the  selection  of  the  installation  directory)  can  be
283           obtained by running
284    
285           ./configure --help           ./configure --help
286    
287         The following sections include  descriptions  of  options  whose  names         The  following  sections  include  descriptions  of options whose names
288         begin with --enable or --disable. These settings specify changes to the         begin with --enable or --disable. These settings specify changes to the
289         defaults for the configure command. Because of the way  that  configure         defaults  for  the configure command. Because of the way that configure
290         works,  --enable  and --disable always come in pairs, so the complemen-         works, --enable and --disable always come in pairs, so  the  complemen-
291         tary option always exists as well, but as it specifies the default,  it         tary  option always exists as well, but as it specifies the default, it
292         is not described.         is not described.
293    
294    
# Line 304  UTF-8 SUPPORT Line 309  UTF-8 SUPPORT
309    
310           --enable-utf8           --enable-utf8
311    
312         to  the  configure  command.  Of  itself, this does not make PCRE treat         to the configure command. Of itself, this  does  not  make  PCRE  treat
313         strings as UTF-8. As well as compiling PCRE with this option, you  also         strings  as UTF-8. As well as compiling PCRE with this option, you also
314         have  have to set the PCRE_UTF8 option when you call the pcre_compile()         have have to set the PCRE_UTF8 option when you call the  pcre_compile()
315         function.         function.
316    
317    
318  UNICODE CHARACTER PROPERTY SUPPORT  UNICODE CHARACTER PROPERTY SUPPORT
319    
320         UTF-8 support allows PCRE to process character values greater than  255         UTF-8  support allows PCRE to process character values greater than 255
321         in  the  strings that it handles. On its own, however, it does not pro-         in the strings that it handles. On its own, however, it does  not  pro-
322         vide any facilities for accessing the properties of such characters. If         vide any facilities for accessing the properties of such characters. If
323         you  want  to  be able to use the pattern escapes \P, \p, and \X, which         you want to be able to use the pattern escapes \P, \p,  and  \X,  which
324         refer to Unicode character properties, you must add         refer to Unicode character properties, you must add
325    
326           --enable-unicode-properties           --enable-unicode-properties
327    
328         to the configure command. This implies UTF-8 support, even if you  have         to  the configure command. This implies UTF-8 support, even if you have
329         not explicitly requested it.         not explicitly requested it.
330    
331         Including  Unicode  property  support  adds around 30K of tables to the         Including Unicode property support adds around 30K  of  tables  to  the
332         PCRE library. Only the general category properties such as  Lu  and  Nd         PCRE  library.  Only  the general category properties such as Lu and Nd
333         are supported. Details are given in the pcrepattern documentation.         are supported. Details are given in the pcrepattern documentation.
334    
335    
336  CODE VALUE OF NEWLINE  CODE VALUE OF NEWLINE
337    
338         By  default,  PCRE interprets character 10 (linefeed, LF) as indicating         By default, PCRE interprets character 10 (linefeed, LF)  as  indicating
339         the end of a line. This is the normal newline  character  on  Unix-like         the  end  of  a line. This is the normal newline character on Unix-like
340         systems. You can compile PCRE to use character 13 (carriage return, CR)         systems. You can compile PCRE to use character 13 (carriage return, CR)
341         instead, by adding         instead, by adding
342    
343           --enable-newline-is-cr           --enable-newline-is-cr
344    
345         to the  configure  command.  There  is  also  a  --enable-newline-is-lf         to  the  configure  command.  There  is  also  a --enable-newline-is-lf
346         option, which explicitly specifies linefeed as the newline character.         option, which explicitly specifies linefeed as the newline character.
347    
348         Alternatively, you can specify that line endings are to be indicated by         Alternatively, you can specify that line endings are to be indicated by
# Line 349  CODE VALUE OF NEWLINE Line 354  CODE VALUE OF NEWLINE
354    
355           --enable-newline-is-anycrlf           --enable-newline-is-anycrlf
356    
357         which causes PCRE to recognize any of the three sequences  CR,  LF,  or         which  causes  PCRE  to recognize any of the three sequences CR, LF, or
358         CRLF as indicating a line ending. Finally, a fifth option, specified by         CRLF as indicating a line ending. Finally, a fifth option, specified by
359    
360           --enable-newline-is-any           --enable-newline-is-any
361    
362         causes PCRE to recognize any Unicode newline sequence.         causes PCRE to recognize any Unicode newline sequence.
363    
364         Whatever line ending convention is selected when PCRE is built  can  be         Whatever  line  ending convention is selected when PCRE is built can be
365         overridden  when  the library functions are called. At build time it is         overridden when the library functions are called. At build time  it  is
366         conventional to use the standard for your operating system.         conventional to use the standard for your operating system.
367    
368    
369  WHAT \R MATCHES  WHAT \R MATCHES
370    
371         By default, the sequence \R in a pattern matches  any  Unicode  newline         By  default,  the  sequence \R in a pattern matches any Unicode newline
372         sequence,  whatever  has  been selected as the line ending sequence. If         sequence, whatever has been selected as the line  ending  sequence.  If
373         you specify         you specify
374    
375           --enable-bsr-anycrlf           --enable-bsr-anycrlf
376    
377         the default is changed so that \R matches only CR, LF, or  CRLF.  What-         the  default  is changed so that \R matches only CR, LF, or CRLF. What-
378         ever  is selected when PCRE is built can be overridden when the library         ever is selected when PCRE is built can be overridden when the  library
379         functions are called.         functions are called.
380    
381    
382  BUILDING SHARED AND STATIC LIBRARIES  BUILDING SHARED AND STATIC LIBRARIES
383    
384         The PCRE building process uses libtool to build both shared and  static         The  PCRE building process uses libtool to build both shared and static
385         Unix  libraries by default. You can suppress one of these by adding one         Unix libraries by default. You can suppress one of these by adding  one
386         of         of
387    
388           --disable-shared           --disable-shared
# Line 389  BUILDING SHARED AND STATIC LIBRARIES Line 394  BUILDING SHARED AND STATIC LIBRARIES
394  POSIX MALLOC USAGE  POSIX MALLOC USAGE
395    
396         When PCRE is called through the POSIX interface (see the pcreposix doc-         When PCRE is called through the POSIX interface (see the pcreposix doc-
397         umentation),  additional  working  storage  is required for holding the         umentation), additional working storage is  required  for  holding  the
398         pointers to capturing substrings, because PCRE requires three  integers         pointers  to capturing substrings, because PCRE requires three integers
399         per  substring,  whereas  the POSIX interface provides only two. If the         per substring, whereas the POSIX interface provides only  two.  If  the
400         number of expected substrings is small, the wrapper function uses space         number of expected substrings is small, the wrapper function uses space
401         on the stack, because this is faster than using malloc() for each call.         on the stack, because this is faster than using malloc() for each call.
402         The default threshold above which the stack is no longer used is 10; it         The default threshold above which the stack is no longer used is 10; it
# Line 404  POSIX MALLOC USAGE Line 409  POSIX MALLOC USAGE
409    
410  HANDLING VERY LARGE PATTERNS  HANDLING VERY LARGE PATTERNS
411    
412         Within  a  compiled  pattern,  offset values are used to point from one         Within a compiled pattern, offset values are used  to  point  from  one
413         part to another (for example, from an opening parenthesis to an  alter-         part  to another (for example, from an opening parenthesis to an alter-
414         nation  metacharacter).  By default, two-byte values are used for these         nation metacharacter). By default, two-byte values are used  for  these
415         offsets, leading to a maximum size for a  compiled  pattern  of  around         offsets,  leading  to  a  maximum size for a compiled pattern of around
416         64K.  This  is sufficient to handle all but the most gigantic patterns.         64K. This is sufficient to handle all but the most  gigantic  patterns.
417         Nevertheless, some people do want to process enormous patterns,  so  it         Nevertheless,  some  people do want to process enormous patterns, so it
418         is  possible  to compile PCRE to use three-byte or four-byte offsets by         is possible to compile PCRE to use three-byte or four-byte  offsets  by
419         adding a setting such as         adding a setting such as
420    
421           --with-link-size=3           --with-link-size=3
422    
423         to the configure command. The value given must be 2,  3,  or  4.  Using         to  the  configure  command.  The value given must be 2, 3, or 4. Using
424         longer  offsets slows down the operation of PCRE because it has to load         longer offsets slows down the operation of PCRE because it has to  load
425         additional bytes when handling them.         additional bytes when handling them.
426    
427    
428  AVOIDING EXCESSIVE STACK USAGE  AVOIDING EXCESSIVE STACK USAGE
429    
430         When matching with the pcre_exec() function, PCRE implements backtrack-         When matching with the pcre_exec() function, PCRE implements backtrack-
431         ing  by  making recursive calls to an internal function called match().         ing by making recursive calls to an internal function  called  match().
432         In environments where the size of the stack is limited,  this  can  se-         In  environments  where  the size of the stack is limited, this can se-
433         verely  limit  PCRE's operation. (The Unix environment does not usually         verely limit PCRE's operation. (The Unix environment does  not  usually
434         suffer from this problem, but it may sometimes be necessary to increase         suffer from this problem, but it may sometimes be necessary to increase
435         the  maximum  stack size.  There is a discussion in the pcrestack docu-         the maximum stack size.  There is a discussion in the  pcrestack  docu-
436         mentation.) An alternative approach to recursion that uses memory  from         mentation.)  An alternative approach to recursion that uses memory from
437         the  heap  to remember data, instead of using recursive function calls,         the heap to remember data, instead of using recursive  function  calls,
438         has been implemented to work round the problem of limited  stack  size.         has  been  implemented to work round the problem of limited stack size.
439         If you want to build a version of PCRE that works this way, add         If you want to build a version of PCRE that works this way, add
440    
441           --disable-stack-for-recursion           --disable-stack-for-recursion
442    
443         to  the  configure  command. With this configuration, PCRE will use the         to the configure command. With this configuration, PCRE  will  use  the
444         pcre_stack_malloc and pcre_stack_free variables to call memory  manage-         pcre_stack_malloc  and pcre_stack_free variables to call memory manage-
445         ment  functions. By default these point to malloc() and free(), but you         ment functions. By default these point to malloc() and free(), but  you
446         can replace the pointers so that your own functions are used.         can replace the pointers so that your own functions are used.
447    
448         Separate functions are  provided  rather  than  using  pcre_malloc  and         Separate  functions  are  provided  rather  than  using pcre_malloc and
449         pcre_free  because  the  usage  is  very  predictable:  the block sizes         pcre_free because the  usage  is  very  predictable:  the  block  sizes
450         requested are always the same, and  the  blocks  are  always  freed  in         requested  are  always  the  same,  and  the blocks are always freed in
451         reverse  order.  A calling program might be able to implement optimized         reverse order. A calling program might be able to  implement  optimized
452         functions that perform better  than  malloc()  and  free().  PCRE  runs         functions  that  perform  better  than  malloc()  and free(). PCRE runs
453         noticeably more slowly when built in this way. This option affects only         noticeably more slowly when built in this way. This option affects only
454         the  pcre_exec()  function;  it   is   not   relevant   for   the   the         the   pcre_exec()   function;   it   is   not   relevant  for  the  the
455         pcre_dfa_exec() function.         pcre_dfa_exec() function.
456    
457    
458  LIMITING PCRE RESOURCE USAGE  LIMITING PCRE RESOURCE USAGE
459    
460         Internally,  PCRE has a function called match(), which it calls repeat-         Internally, PCRE has a function called match(), which it calls  repeat-
461         edly  (sometimes  recursively)  when  matching  a  pattern   with   the         edly   (sometimes   recursively)  when  matching  a  pattern  with  the
462         pcre_exec()  function.  By controlling the maximum number of times this         pcre_exec() function. By controlling the maximum number of  times  this
463         function may be called during a single matching operation, a limit  can         function  may be called during a single matching operation, a limit can
464         be  placed  on  the resources used by a single call to pcre_exec(). The         be placed on the resources used by a single call  to  pcre_exec().  The
465         limit can be changed at run time, as described in the pcreapi  documen-         limit  can be changed at run time, as described in the pcreapi documen-
466         tation.  The default is 10 million, but this can be changed by adding a         tation. The default is 10 million, but this can be changed by adding  a
467         setting such as         setting such as
468    
469           --with-match-limit=500000           --with-match-limit=500000
470    
471         to  the  configure  command.  This  setting  has  no  effect   on   the         to   the   configure  command.  This  setting  has  no  effect  on  the
472         pcre_dfa_exec() matching function.         pcre_dfa_exec() matching function.
473    
474         In  some  environments  it is desirable to limit the depth of recursive         In some environments it is desirable to limit the  depth  of  recursive
475         calls of match() more strictly than the total number of calls, in order         calls of match() more strictly than the total number of calls, in order
476         to  restrict  the maximum amount of stack (or heap, if --disable-stack-         to restrict the maximum amount of stack (or heap,  if  --disable-stack-
477         for-recursion is specified) that is used. A second limit controls this;         for-recursion is specified) that is used. A second limit controls this;
478         it  defaults  to  the  value  that is set for --with-match-limit, which         it defaults to the value that  is  set  for  --with-match-limit,  which
479         imposes no additional constraints. However, you can set a  lower  limit         imposes  no  additional constraints. However, you can set a lower limit
480         by adding, for example,         by adding, for example,
481    
482           --with-match-limit-recursion=10000           --with-match-limit-recursion=10000
483    
484         to  the  configure  command.  This  value can also be overridden at run         to the configure command. This value can  also  be  overridden  at  run
485         time.         time.
486    
487    
488  CREATING CHARACTER TABLES AT BUILD TIME  CREATING CHARACTER TABLES AT BUILD TIME
489    
490         PCRE uses fixed tables for processing characters whose code values  are         PCRE  uses fixed tables for processing characters whose code values are
491         less  than 256. By default, PCRE is built with a set of tables that are         less than 256. By default, PCRE is built with a set of tables that  are
492         distributed in the file pcre_chartables.c.dist. These  tables  are  for         distributed  in  the  file pcre_chartables.c.dist. These tables are for
493         ASCII codes only. If you add         ASCII codes only. If you add
494    
495           --enable-rebuild-chartables           --enable-rebuild-chartables
496    
497         to  the  configure  command, the distributed tables are no longer used.         to the configure command, the distributed tables are  no  longer  used.
498         Instead, a program called dftables is compiled and  run.  This  outputs         Instead,  a  program  called dftables is compiled and run. This outputs
499         the source for new set of tables, created in the default locale of your         the source for new set of tables, created in the default locale of your
500         C runtime system. (This method of replacing the tables does not work if         C runtime system. (This method of replacing the tables does not work if
501         you  are cross compiling, because dftables is run on the local host. If         you are cross compiling, because dftables is run on the local host.  If
502         you need to create alternative tables when cross  compiling,  you  will         you  need  to  create alternative tables when cross compiling, you will
503         have to do so "by hand".)         have to do so "by hand".)
504    
505    
506  USING EBCDIC CODE  USING EBCDIC CODE
507    
508         PCRE  assumes  by  default that it will run in an environment where the         PCRE assumes by default that it will run in an  environment  where  the
509         character code is ASCII (or Unicode, which is  a  superset  of  ASCII).         character  code  is  ASCII  (or Unicode, which is a superset of ASCII).
510         This  is  the  case for most computer operating systems. PCRE can, how-         This is the case for most computer operating systems.  PCRE  can,  how-
511         ever, be compiled to run in an EBCDIC environment by adding         ever, be compiled to run in an EBCDIC environment by adding
512    
513           --enable-ebcdic           --enable-ebcdic
514    
515         to the configure command. This setting implies --enable-rebuild-charta-         to the configure command. This setting implies --enable-rebuild-charta-
516         bles.  You  should  only  use  it if you know that you are in an EBCDIC         bles. You should only use it if you know that  you  are  in  an  EBCDIC
517         environment (for example, an IBM mainframe operating system).         environment (for example, an IBM mainframe operating system).
518    
519    
520    PCREGREP OPTIONS FOR COMPRESSED FILE SUPPORT
521    
522           By default, pcregrep reads all files as plain text. You can build it so
523           that it recognizes files whose names end in .gz or .bz2, and reads them
524           with libz or libbz2, respectively, by adding one or both of
525    
526             --enable-pcregrep-libz
527             --enable-pcregrep-libbz2
528    
529           to the configure command. These options naturally require that the rel-
530           evant libraries are installed on your system. Configuration  will  fail
531           if they are not.
532    
533    
534    PCRETEST OPTION FOR LIBREADLINE SUPPORT
535    
536           If you add
537    
538             --enable-pcretest-libreadline
539    
540           to  the  configure  command,  pcretest  is  linked with the libreadline
541           library, and when its input is from a terminal, it reads it  using  the
542           readline() function. This provides line-editing and history facilities.
543           Note that libreadline is GPL-licenced, so if you distribute a binary of
544           pcretest linked in this way, there may be licensing issues.
545    
546    
547  SEE ALSO  SEE ALSO
548    
549         pcreapi(3), pcre_config(3).         pcreapi(3), pcre_config(3).
# Line 526  AUTHOR Line 558  AUTHOR
558    
559  REVISION  REVISION
560    
561         Last updated: 11 September 2007         Last updated: 18 December 2007
562         Copyright (c) 1997-2007 University of Cambridge.         Copyright (c) 1997-2007 University of Cambridge.
563  ------------------------------------------------------------------------------  ------------------------------------------------------------------------------
564    
# Line 1565  INFORMATION ABOUT A PATTERN Line 1597  INFORMATION ABOUT A PATTERN
1597    
1598         Return  1  if  the  pattern  contains any explicit matches for CR or LF         Return  1  if  the  pattern  contains any explicit matches for CR or LF
1599         characters, otherwise 0. The fourth argument should  point  to  an  int         characters, otherwise 0. The fourth argument should  point  to  an  int
1600         variable.         variable.  An explicit match is either a literal CR or LF character, or
1601           \r or \n.
1602    
1603           PCRE_INFO_JCHANGED           PCRE_INFO_JCHANGED
1604    
1605         Return  1  if the (?J) option setting is used in the pattern, otherwise         Return 1 if the (?J) or (?-J) option setting is used  in  the  pattern,
1606         0. The fourth argument should point to an int variable. The (?J) inter-         otherwise  0. The fourth argument should point to an int variable. (?J)
1607         nal option setting changes the local PCRE_DUPNAMES option.         and (?-J) set and unset the local PCRE_DUPNAMES option, respectively.
1608    
1609           PCRE_INFO_LASTLITERAL           PCRE_INFO_LASTLITERAL
1610    
1611         Return  the  value of the rightmost literal byte that must exist in any         Return the value of the rightmost literal byte that must exist  in  any
1612         matched string, other than at its  start,  if  such  a  byte  has  been         matched  string,  other  than  at  its  start,  if such a byte has been
1613         recorded. The fourth argument should point to an int variable. If there         recorded. The fourth argument should point to an int variable. If there
1614         is no such byte, -1 is returned. For anchored patterns, a last  literal         is  no such byte, -1 is returned. For anchored patterns, a last literal
1615         byte  is  recorded only if it follows something of variable length. For         byte is recorded only if it follows something of variable  length.  For
1616         example, for the pattern /^a\d+z\d+/ the returned value is "z", but for         example, for the pattern /^a\d+z\d+/ the returned value is "z", but for
1617         /^a\dz\d/ the returned value is -1.         /^a\dz\d/ the returned value is -1.
1618    
# Line 1587  INFORMATION ABOUT A PATTERN Line 1620  INFORMATION ABOUT A PATTERN
1620           PCRE_INFO_NAMEENTRYSIZE           PCRE_INFO_NAMEENTRYSIZE
1621           PCRE_INFO_NAMETABLE           PCRE_INFO_NAMETABLE
1622    
1623         PCRE  supports the use of named as well as numbered capturing parenthe-         PCRE supports the use of named as well as numbered capturing  parenthe-
1624         ses. The names are just an additional way of identifying the  parenthe-         ses.  The names are just an additional way of identifying the parenthe-
1625         ses, which still acquire numbers. Several convenience functions such as         ses, which still acquire numbers. Several convenience functions such as
1626         pcre_get_named_substring() are provided for  extracting  captured  sub-         pcre_get_named_substring()  are  provided  for extracting captured sub-
1627         strings  by  name. It is also possible to extract the data directly, by         strings by name. It is also possible to extract the data  directly,  by
1628         first converting the name to a number in order to  access  the  correct         first  converting  the  name to a number in order to access the correct
1629         pointers in the output vector (described with pcre_exec() below). To do         pointers in the output vector (described with pcre_exec() below). To do
1630         the conversion, you need  to  use  the  name-to-number  map,  which  is         the  conversion,  you  need  to  use  the  name-to-number map, which is
1631         described by these three values.         described by these three values.
1632    
1633         The map consists of a number of fixed-size entries. PCRE_INFO_NAMECOUNT         The map consists of a number of fixed-size entries. PCRE_INFO_NAMECOUNT
1634         gives the number of entries, and PCRE_INFO_NAMEENTRYSIZE gives the size         gives the number of entries, and PCRE_INFO_NAMEENTRYSIZE gives the size
1635         of  each  entry;  both  of  these  return  an int value. The entry size         of each entry; both of these  return  an  int  value.  The  entry  size
1636         depends on the length of the longest name. PCRE_INFO_NAMETABLE  returns         depends  on the length of the longest name. PCRE_INFO_NAMETABLE returns
1637         a  pointer  to  the  first  entry of the table (a pointer to char). The         a pointer to the first entry of the table  (a  pointer  to  char).  The
1638         first two bytes of each entry are the number of the capturing parenthe-         first two bytes of each entry are the number of the capturing parenthe-
1639         sis,  most  significant byte first. The rest of the entry is the corre-         sis, most significant byte first. The rest of the entry is  the  corre-
1640         sponding name, zero terminated. The names are  in  alphabetical  order.         sponding  name,  zero  terminated. The names are in alphabetical order.
1641         When PCRE_DUPNAMES is set, duplicate names are in order of their paren-         When PCRE_DUPNAMES is set, duplicate names are in order of their paren-
1642         theses numbers. For example, consider  the  following  pattern  (assume         theses  numbers.  For  example,  consider the following pattern (assume
1643         PCRE_EXTENDED  is  set,  so  white  space  -  including  newlines  - is         PCRE_EXTENDED is  set,  so  white  space  -  including  newlines  -  is
1644         ignored):         ignored):
1645    
1646           (?<date> (?<year>(\d\d)?\d\d) -           (?<date> (?<year>(\d\d)?\d\d) -
1647           (?<month>\d\d) - (?<day>\d\d) )           (?<month>\d\d) - (?<day>\d\d) )
1648    
1649         There are four named subpatterns, so the table has  four  entries,  and         There  are  four  named subpatterns, so the table has four entries, and
1650         each  entry  in the table is eight bytes long. The table is as follows,         each entry in the table is eight bytes long. The table is  as  follows,
1651         with non-printing bytes shows in hexadecimal, and undefined bytes shown         with non-printing bytes shows in hexadecimal, and undefined bytes shown
1652         as ??:         as ??:
1653    
# Line 1623  INFORMATION ABOUT A PATTERN Line 1656  INFORMATION ABOUT A PATTERN
1656           00 04 m  o  n  t  h  00           00 04 m  o  n  t  h  00
1657           00 02 y  e  a  r  00 ??           00 02 y  e  a  r  00 ??
1658    
1659         When  writing  code  to  extract  data from named subpatterns using the         When writing code to extract data  from  named  subpatterns  using  the
1660         name-to-number map, remember that the length of the entries  is  likely         name-to-number  map,  remember that the length of the entries is likely
1661         to be different for each compiled pattern.         to be different for each compiled pattern.
1662    
1663           PCRE_INFO_OKPARTIAL           PCRE_INFO_OKPARTIAL
1664    
1665         Return  1 if the pattern can be used for partial matching, otherwise 0.         Return 1 if the pattern can be used for partial matching, otherwise  0.
1666         The fourth argument should point to an int  variable.  The  pcrepartial         The  fourth  argument  should point to an int variable. The pcrepartial
1667         documentation  lists  the restrictions that apply to patterns when par-         documentation lists the restrictions that apply to patterns  when  par-
1668         tial matching is used.         tial matching is used.
1669    
1670           PCRE_INFO_OPTIONS           PCRE_INFO_OPTIONS
1671    
1672         Return a copy of the options with which the pattern was  compiled.  The         Return  a  copy of the options with which the pattern was compiled. The
1673         fourth  argument  should  point to an unsigned long int variable. These         fourth argument should point to an unsigned long  int  variable.  These
1674         option bits are those specified in the call to pcre_compile(), modified         option bits are those specified in the call to pcre_compile(), modified
1675         by any top-level option settings at the start of the pattern itself. In         by any top-level option settings at the start of the pattern itself. In
1676         other words, they are the options that will be in force  when  matching         other  words,  they are the options that will be in force when matching
1677         starts.  For  example, if the pattern /(?im)abc(?-i)d/ is compiled with         starts. For example, if the pattern /(?im)abc(?-i)d/ is  compiled  with
1678         the PCRE_EXTENDED option, the result is PCRE_CASELESS,  PCRE_MULTILINE,         the  PCRE_EXTENDED option, the result is PCRE_CASELESS, PCRE_MULTILINE,
1679         and PCRE_EXTENDED.         and PCRE_EXTENDED.
1680    
1681         A  pattern  is  automatically  anchored by PCRE if all of its top-level         A pattern is automatically anchored by PCRE if  all  of  its  top-level
1682         alternatives begin with one of the following:         alternatives begin with one of the following:
1683    
1684           ^     unless PCRE_MULTILINE is set           ^     unless PCRE_MULTILINE is set
# Line 1659  INFORMATION ABOUT A PATTERN Line 1692  INFORMATION ABOUT A PATTERN
1692    
1693           PCRE_INFO_SIZE           PCRE_INFO_SIZE
1694    
1695         Return  the  size  of the compiled pattern, that is, the value that was         Return the size of the compiled pattern, that is, the  value  that  was
1696         passed as the argument to pcre_malloc() when PCRE was getting memory in         passed as the argument to pcre_malloc() when PCRE was getting memory in
1697         which to place the compiled data. The fourth argument should point to a         which to place the compiled data. The fourth argument should point to a
1698         size_t variable.         size_t variable.
# Line 1667  INFORMATION ABOUT A PATTERN Line 1700  INFORMATION ABOUT A PATTERN
1700           PCRE_INFO_STUDYSIZE           PCRE_INFO_STUDYSIZE
1701    
1702         Return the size of the data block pointed to by the study_data field in         Return the size of the data block pointed to by the study_data field in
1703         a  pcre_extra  block.  That  is,  it  is  the  value that was passed to         a pcre_extra block. That is,  it  is  the  value  that  was  passed  to
1704         pcre_malloc() when PCRE was getting memory into which to place the data         pcre_malloc() when PCRE was getting memory into which to place the data
1705         created  by  pcre_study(). The fourth argument should point to a size_t         created by pcre_study(). The fourth argument should point to  a  size_t
1706         variable.         variable.
1707    
1708    
# Line 1677  OBSOLETE INFO FUNCTION Line 1710  OBSOLETE INFO FUNCTION
1710    
1711         int pcre_info(const pcre *code, int *optptr, int *firstcharptr);         int pcre_info(const pcre *code, int *optptr, int *firstcharptr);
1712    
1713         The pcre_info() function is now obsolete because its interface  is  too         The  pcre_info()  function is now obsolete because its interface is too
1714         restrictive  to return all the available data about a compiled pattern.         restrictive to return all the available data about a compiled  pattern.
1715         New  programs  should  use  pcre_fullinfo()  instead.  The   yield   of         New   programs   should  use  pcre_fullinfo()  instead.  The  yield  of
1716         pcre_info()  is the number of capturing subpatterns, or one of the fol-         pcre_info() is the number of capturing subpatterns, or one of the  fol-
1717         lowing negative numbers:         lowing negative numbers:
1718    
1719           PCRE_ERROR_NULL       the argument code was NULL           PCRE_ERROR_NULL       the argument code was NULL
1720           PCRE_ERROR_BADMAGIC   the "magic number" was not found           PCRE_ERROR_BADMAGIC   the "magic number" was not found
1721    
1722         If the optptr argument is not NULL, a copy of the  options  with  which         If  the  optptr  argument is not NULL, a copy of the options with which
1723         the  pattern  was  compiled  is placed in the integer it points to (see         the pattern was compiled is placed in the integer  it  points  to  (see
1724         PCRE_INFO_OPTIONS above).         PCRE_INFO_OPTIONS above).
1725    
1726         If the pattern is not anchored and the  firstcharptr  argument  is  not         If  the  pattern  is  not anchored and the firstcharptr argument is not
1727         NULL,  it is used to pass back information about the first character of         NULL, it is used to pass back information about the first character  of
1728         any matched string (see PCRE_INFO_FIRSTBYTE above).         any matched string (see PCRE_INFO_FIRSTBYTE above).
1729    
1730    
# Line 1699  REFERENCE COUNTS Line 1732  REFERENCE COUNTS
1732    
1733         int pcre_refcount(pcre *code, int adjust);         int pcre_refcount(pcre *code, int adjust);
1734    
1735         The pcre_refcount() function is used to maintain a reference  count  in         The  pcre_refcount()  function is used to maintain a reference count in
1736         the data block that contains a compiled pattern. It is provided for the         the data block that contains a compiled pattern. It is provided for the
1737         benefit of applications that  operate  in  an  object-oriented  manner,         benefit  of  applications  that  operate  in an object-oriented manner,
1738         where different parts of the application may be using the same compiled         where different parts of the application may be using the same compiled
1739         pattern, but you want to free the block when they are all done.         pattern, but you want to free the block when they are all done.
1740    
1741         When a pattern is compiled, the reference count field is initialized to         When a pattern is compiled, the reference count field is initialized to
1742         zero.   It is changed only by calling this function, whose action is to         zero.  It is changed only by calling this function, whose action is  to
1743         add the adjust value (which may be positive or  negative)  to  it.  The         add  the  adjust  value  (which may be positive or negative) to it. The
1744         yield of the function is the new value. However, the value of the count         yield of the function is the new value. However, the value of the count
1745         is constrained to lie between 0 and 65535, inclusive. If the new  value         is  constrained to lie between 0 and 65535, inclusive. If the new value
1746         is outside these limits, it is forced to the appropriate limit value.         is outside these limits, it is forced to the appropriate limit value.
1747    
1748         Except  when it is zero, the reference count is not correctly preserved         Except when it is zero, the reference count is not correctly  preserved
1749         if a pattern is compiled on one host and then  transferred  to  a  host         if  a  pattern  is  compiled on one host and then transferred to a host
1750         whose byte-order is different. (This seems a highly unlikely scenario.)         whose byte-order is different. (This seems a highly unlikely scenario.)
1751    
1752    
# Line 1723  MATCHING A PATTERN: THE TRADITIONAL FUNC Line 1756  MATCHING A PATTERN: THE TRADITIONAL FUNC
1756              const char *subject, int length, int startoffset,              const char *subject, int length, int startoffset,
1757              int options, int *ovector, int ovecsize);              int options, int *ovector, int ovecsize);
1758    
1759         The function pcre_exec() is called to match a subject string against  a         The  function pcre_exec() is called to match a subject string against a
1760         compiled  pattern, which is passed in the code argument. If the pattern         compiled pattern, which is passed in the code argument. If the  pattern
1761         has been studied, the result of the study should be passed in the extra         has been studied, the result of the study should be passed in the extra
1762         argument.  This  function is the main matching facility of the library,         argument. This function is the main matching facility of  the  library,
1763         and it operates in a Perl-like manner. For specialist use there is also         and it operates in a Perl-like manner. For specialist use there is also
1764         an  alternative matching function, which is described below in the sec-         an alternative matching function, which is described below in the  sec-
1765         tion about the pcre_dfa_exec() function.         tion about the pcre_dfa_exec() function.
1766    
1767         In most applications, the pattern will have been compiled (and  option-         In  most applications, the pattern will have been compiled (and option-
1768         ally  studied)  in the same process that calls pcre_exec(). However, it         ally studied) in the same process that calls pcre_exec().  However,  it
1769         is possible to save compiled patterns and study data, and then use them         is possible to save compiled patterns and study data, and then use them
1770         later  in  different processes, possibly even on different hosts. For a         later in different processes, possibly even on different hosts.  For  a
1771         discussion about this, see the pcreprecompile documentation.         discussion about this, see the pcreprecompile documentation.
1772    
1773         Here is an example of a simple call to pcre_exec():         Here is an example of a simple call to pcre_exec():
# Line 1753  MATCHING A PATTERN: THE TRADITIONAL FUNC Line 1786  MATCHING A PATTERN: THE TRADITIONAL FUNC
1786    
1787     Extra data for pcre_exec()     Extra data for pcre_exec()
1788    
1789         If the extra argument is not NULL, it must point to a  pcre_extra  data         If  the  extra argument is not NULL, it must point to a pcre_extra data
1790         block.  The pcre_study() function returns such a block (when it doesn't         block. The pcre_study() function returns such a block (when it  doesn't
1791         return NULL), but you can also create one for yourself, and pass  addi-         return  NULL), but you can also create one for yourself, and pass addi-
1792         tional  information  in it. The pcre_extra block contains the following         tional information in it. The pcre_extra block contains  the  following
1793         fields (not necessarily in this order):         fields (not necessarily in this order):
1794    
1795           unsigned long int flags;           unsigned long int flags;
# Line 1766  MATCHING A PATTERN: THE TRADITIONAL FUNC Line 1799  MATCHING A PATTERN: THE TRADITIONAL FUNC
1799           void *callout_data;           void *callout_data;
1800           const unsigned char *tables;           const unsigned char *tables;
1801    
1802         The flags field is a bitmap that specifies which of  the  other  fields         The  flags  field  is a bitmap that specifies which of the other fields
1803         are set. The flag bits are:         are set. The flag bits are:
1804    
1805           PCRE_EXTRA_STUDY_DATA           PCRE_EXTRA_STUDY_DATA
# Line 1775  MATCHING A PATTERN: THE TRADITIONAL FUNC Line 1808  MATCHING A PATTERN: THE TRADITIONAL FUNC
1808           PCRE_EXTRA_CALLOUT_DATA           PCRE_EXTRA_CALLOUT_DATA
1809           PCRE_EXTRA_TABLES           PCRE_EXTRA_TABLES
1810    
1811         Other  flag  bits should be set to zero. The study_data field is set in         Other flag bits should be set to zero. The study_data field is  set  in
1812         the pcre_extra block that is returned by  pcre_study(),  together  with         the  pcre_extra  block  that is returned by pcre_study(), together with
1813         the appropriate flag bit. You should not set this yourself, but you may         the appropriate flag bit. You should not set this yourself, but you may
1814         add to the block by setting the other fields  and  their  corresponding         add  to  the  block by setting the other fields and their corresponding
1815         flag bits.         flag bits.
1816    
1817         The match_limit field provides a means of preventing PCRE from using up         The match_limit field provides a means of preventing PCRE from using up
1818         a vast amount of resources when running patterns that are not going  to         a  vast amount of resources when running patterns that are not going to
1819         match,  but  which  have  a very large number of possibilities in their         match, but which have a very large number  of  possibilities  in  their
1820         search trees. The classic  example  is  the  use  of  nested  unlimited         search  trees.  The  classic  example  is  the  use of nested unlimited
1821         repeats.         repeats.
1822    
1823         Internally,  PCRE uses a function called match() which it calls repeat-         Internally, PCRE uses a function called match() which it calls  repeat-
1824         edly (sometimes recursively). The limit set by match_limit  is  imposed         edly  (sometimes  recursively). The limit set by match_limit is imposed
1825         on  the  number  of times this function is called during a match, which         on the number of times this function is called during  a  match,  which
1826         has the effect of limiting the amount of  backtracking  that  can  take         has  the  effect  of  limiting the amount of backtracking that can take
1827         place. For patterns that are not anchored, the count restarts from zero         place. For patterns that are not anchored, the count restarts from zero
1828         for each position in the subject string.         for each position in the subject string.
1829    
1830         The default value for the limit can be set  when  PCRE  is  built;  the         The  default  value  for  the  limit can be set when PCRE is built; the
1831         default  default  is 10 million, which handles all but the most extreme         default default is 10 million, which handles all but the  most  extreme
1832         cases. You can override the default  by  suppling  pcre_exec()  with  a         cases.  You  can  override  the  default by suppling pcre_exec() with a
1833         pcre_extra     block    in    which    match_limit    is    set,    and         pcre_extra    block    in    which    match_limit    is    set,     and
1834         PCRE_EXTRA_MATCH_LIMIT is set in the  flags  field.  If  the  limit  is         PCRE_EXTRA_MATCH_LIMIT  is  set  in  the  flags  field. If the limit is
1835         exceeded, pcre_exec() returns PCRE_ERROR_MATCHLIMIT.         exceeded, pcre_exec() returns PCRE_ERROR_MATCHLIMIT.
1836    
1837         The  match_limit_recursion field is similar to match_limit, but instead         The match_limit_recursion field is similar to match_limit, but  instead
1838         of limiting the total number of times that match() is called, it limits         of limiting the total number of times that match() is called, it limits
1839         the  depth  of  recursion. The recursion depth is a smaller number than         the depth of recursion. The recursion depth is a  smaller  number  than
1840         the total number of calls, because not all calls to match() are  recur-         the  total number of calls, because not all calls to match() are recur-
1841         sive.  This limit is of use only if it is set smaller than match_limit.         sive.  This limit is of use only if it is set smaller than match_limit.
1842    
1843         Limiting the recursion depth limits the amount of  stack  that  can  be         Limiting  the  recursion  depth  limits the amount of stack that can be
1844         used, or, when PCRE has been compiled to use memory on the heap instead         used, or, when PCRE has been compiled to use memory on the heap instead
1845         of the stack, the amount of heap memory that can be used.         of the stack, the amount of heap memory that can be used.
1846    
1847         The default value for match_limit_recursion can be  set  when  PCRE  is         The  default  value  for  match_limit_recursion can be set when PCRE is
1848         built;  the  default  default  is  the  same  value  as the default for         built; the default default  is  the  same  value  as  the  default  for
1849         match_limit. You can override the default by suppling pcre_exec()  with         match_limit.  You can override the default by suppling pcre_exec() with
1850         a   pcre_extra   block  in  which  match_limit_recursion  is  set,  and         a  pcre_extra  block  in  which  match_limit_recursion  is   set,   and
1851         PCRE_EXTRA_MATCH_LIMIT_RECURSION is set in  the  flags  field.  If  the         PCRE_EXTRA_MATCH_LIMIT_RECURSION  is  set  in  the  flags field. If the
1852         limit is exceeded, pcre_exec() returns PCRE_ERROR_RECURSIONLIMIT.         limit is exceeded, pcre_exec() returns PCRE_ERROR_RECURSIONLIMIT.
1853    
1854         The  pcre_callout  field is used in conjunction with the "callout" fea-         The pcre_callout field is used in conjunction with the  "callout"  fea-
1855         ture, which is described in the pcrecallout documentation.         ture, which is described in the pcrecallout documentation.
1856    
1857         The tables field  is  used  to  pass  a  character  tables  pointer  to         The  tables  field  is  used  to  pass  a  character  tables pointer to
1858         pcre_exec();  this overrides the value that is stored with the compiled         pcre_exec(); this overrides the value that is stored with the  compiled
1859         pattern. A non-NULL value is stored with the compiled pattern  only  if         pattern.  A  non-NULL value is stored with the compiled pattern only if
1860         custom  tables  were  supplied to pcre_compile() via its tableptr argu-         custom tables were supplied to pcre_compile() via  its  tableptr  argu-
1861         ment.  If NULL is passed to pcre_exec() using this mechanism, it forces         ment.  If NULL is passed to pcre_exec() using this mechanism, it forces
1862         PCRE's  internal  tables  to be used. This facility is helpful when re-         PCRE's internal tables to be used. This facility is  helpful  when  re-
1863         using patterns that have been saved after compiling  with  an  external         using  patterns  that  have been saved after compiling with an external
1864         set  of  tables,  because  the  external tables might be at a different         set of tables, because the external tables  might  be  at  a  different
1865         address when pcre_exec() is called. See the  pcreprecompile  documenta-         address  when  pcre_exec() is called. See the pcreprecompile documenta-
1866         tion for a discussion of saving compiled patterns for later use.         tion for a discussion of saving compiled patterns for later use.
1867    
1868     Option bits for pcre_exec()     Option bits for pcre_exec()
1869    
1870         The  unused  bits of the options argument for pcre_exec() must be zero.         The unused bits of the options argument for pcre_exec() must  be  zero.
1871         The only bits that may  be  set  are  PCRE_ANCHORED,  PCRE_NEWLINE_xxx,         The  only  bits  that  may  be set are PCRE_ANCHORED, PCRE_NEWLINE_xxx,
1872         PCRE_NOTBOL,   PCRE_NOTEOL,   PCRE_NOTEMPTY,   PCRE_NO_UTF8_CHECK   and         PCRE_NOTBOL,   PCRE_NOTEOL,   PCRE_NOTEMPTY,   PCRE_NO_UTF8_CHECK   and
1873         PCRE_PARTIAL.         PCRE_PARTIAL.
1874    
1875           PCRE_ANCHORED           PCRE_ANCHORED
1876    
1877         The PCRE_ANCHORED option limits pcre_exec() to matching  at  the  first         The  PCRE_ANCHORED  option  limits pcre_exec() to matching at the first
1878         matching  position.  If  a  pattern was compiled with PCRE_ANCHORED, or         matching position. If a pattern was  compiled  with  PCRE_ANCHORED,  or
1879         turned out to be anchored by virtue of its contents, it cannot be  made         turned  out to be anchored by virtue of its contents, it cannot be made
1880         unachored at matching time.         unachored at matching time.
1881    
1882           PCRE_BSR_ANYCRLF           PCRE_BSR_ANYCRLF
1883           PCRE_BSR_UNICODE           PCRE_BSR_UNICODE
1884    
1885         These options (which are mutually exclusive) control what the \R escape         These options (which are mutually exclusive) control what the \R escape
1886         sequence matches. The choice is either to match only CR, LF,  or  CRLF,         sequence  matches.  The choice is either to match only CR, LF, or CRLF,
1887         or  to  match  any Unicode newline sequence. These options override the         or to match any Unicode newline sequence. These  options  override  the
1888         choice that was made or defaulted when the pattern was compiled.         choice that was made or defaulted when the pattern was compiled.
1889    
1890           PCRE_NEWLINE_CR           PCRE_NEWLINE_CR
# Line 1860  MATCHING A PATTERN: THE TRADITIONAL FUNC Line 1893  MATCHING A PATTERN: THE TRADITIONAL FUNC
1893           PCRE_NEWLINE_ANYCRLF           PCRE_NEWLINE_ANYCRLF
1894           PCRE_NEWLINE_ANY           PCRE_NEWLINE_ANY
1895    
1896         These options override  the  newline  definition  that  was  chosen  or         These  options  override  the  newline  definition  that  was chosen or
1897         defaulted  when the pattern was compiled. For details, see the descrip-         defaulted when the pattern was compiled. For details, see the  descrip-
1898         tion of pcre_compile()  above.  During  matching,  the  newline  choice         tion  of  pcre_compile()  above.  During  matching,  the newline choice
1899         affects  the  behaviour  of the dot, circumflex, and dollar metacharac-         affects the behaviour of the dot, circumflex,  and  dollar  metacharac-
1900         ters. It may also alter the way the match position is advanced after  a         ters.  It may also alter the way the match position is advanced after a
1901         match failure for an unanchored pattern.         match failure for an unanchored pattern.
1902    
1903         When  PCRE_NEWLINE_CRLF,  PCRE_NEWLINE_ANYCRLF,  or PCRE_NEWLINE_ANY is         When PCRE_NEWLINE_CRLF, PCRE_NEWLINE_ANYCRLF,  or  PCRE_NEWLINE_ANY  is
1904         set, and a match attempt for an unanchored pattern fails when the  cur-         set,  and a match attempt for an unanchored pattern fails when the cur-
1905         rent  position  is  at  a  CRLF  sequence,  and the pattern contains no         rent position is at a  CRLF  sequence,  and  the  pattern  contains  no
1906         explicit matches for  CR  or  LF  characters,  the  match  position  is         explicit  matches  for  CR  or  LF  characters,  the  match position is
1907         advanced by two characters instead of one, in other words, to after the         advanced by two characters instead of one, in other words, to after the
1908         CRLF.         CRLF.
1909    
1910         The above rule is a compromise that makes the most common cases work as         The above rule is a compromise that makes the most common cases work as
1911         expected.  For  example,  if  the  pattern  is .+A (and the PCRE_DOTALL         expected. For example, if the  pattern  is  .+A  (and  the  PCRE_DOTALL
1912         option is not set), it does not match the string "\r\nA" because, after         option is not set), it does not match the string "\r\nA" because, after
1913         failing  at the start, it skips both the CR and the LF before retrying.         failing at the start, it skips both the CR and the LF before  retrying.
1914         However, the pattern [\r\n]A does match that string,  because  it  con-         However,  the  pattern  [\r\n]A does match that string, because it con-
1915         tains an explicit CR or LF reference, and so advances only by one char-         tains an explicit CR or LF reference, and so advances only by one char-
1916         acter after the first failure.         acter after the first failure.
1917    
1918         An explicit match for CR of LF is either a literal appearance of one of         An explicit match for CR of LF is either a literal appearance of one of
1919         those  characters,  or  one  of the \r or \n escape sequences. Implicit         those characters, or one of the \r or  \n  escape  sequences.  Implicit
1920         matches such as [^X] do not count, nor does \s (which includes  CR  and         matches  such  as [^X] do not count, nor does \s (which includes CR and
1921         LF in the characters that it matches).         LF in the characters that it matches).
1922    
1923         Notwithstanding  the above, anomalous effects may still occur when CRLF         Notwithstanding the above, anomalous effects may still occur when  CRLF
1924         is a valid newline sequence and explicit \r or \n escapes appear in the         is a valid newline sequence and explicit \r or \n escapes appear in the
1925         pattern.         pattern.
1926    
1927           PCRE_NOTBOL           PCRE_NOTBOL
1928    
1929         This option specifies that first character of the subject string is not         This option specifies that first character of the subject string is not
1930         the beginning of a line, so the  circumflex  metacharacter  should  not         the  beginning  of  a  line, so the circumflex metacharacter should not
1931         match  before it. Setting this without PCRE_MULTILINE (at compile time)         match before it. Setting this without PCRE_MULTILINE (at compile  time)
1932         causes circumflex never to match. This option affects only  the  behav-         causes  circumflex  never to match. This option affects only the behav-
1933         iour of the circumflex metacharacter. It does not affect \A.         iour of the circumflex metacharacter. It does not affect \A.
1934    
1935           PCRE_NOTEOL           PCRE_NOTEOL
1936    
1937         This option specifies that the end of the subject string is not the end         This option specifies that the end of the subject string is not the end
1938         of a line, so the dollar metacharacter should not match it nor  (except         of  a line, so the dollar metacharacter should not match it nor (except
1939         in  multiline mode) a newline immediately before it. Setting this with-         in multiline mode) a newline immediately before it. Setting this  with-
1940         out PCRE_MULTILINE (at compile time) causes dollar never to match. This         out PCRE_MULTILINE (at compile time) causes dollar never to match. This
1941         option  affects only the behaviour of the dollar metacharacter. It does         option affects only the behaviour of the dollar metacharacter. It  does
1942         not affect \Z or \z.         not affect \Z or \z.
1943    
1944           PCRE_NOTEMPTY           PCRE_NOTEMPTY
1945    
1946         An empty string is not considered to be a valid match if this option is         An empty string is not considered to be a valid match if this option is
1947         set.  If  there are alternatives in the pattern, they are tried. If all         set. If there are alternatives in the pattern, they are tried.  If  all
1948         the alternatives match the empty string, the entire  match  fails.  For         the  alternatives  match  the empty string, the entire match fails. For
1949         example, if the pattern         example, if the pattern
1950    
1951           a?b?           a?b?
1952    
1953         is  applied  to  a string not beginning with "a" or "b", it matches the         is applied to a string not beginning with "a" or "b",  it  matches  the
1954         empty string at the start of the subject. With PCRE_NOTEMPTY set,  this         empty  string at the start of the subject. With PCRE_NOTEMPTY set, this
1955         match is not valid, so PCRE searches further into the string for occur-         match is not valid, so PCRE searches further into the string for occur-
1956         rences of "a" or "b".         rences of "a" or "b".
1957    
1958         Perl has no direct equivalent of PCRE_NOTEMPTY, but it does make a spe-         Perl has no direct equivalent of PCRE_NOTEMPTY, but it does make a spe-
1959         cial  case  of  a  pattern match of the empty string within its split()         cial case of a pattern match of the empty  string  within  its  split()
1960         function, and when using the /g modifier. It  is  possible  to  emulate         function,  and  when  using  the /g modifier. It is possible to emulate
1961         Perl's behaviour after matching a null string by first trying the match         Perl's behaviour after matching a null string by first trying the match
1962         again at the same offset with PCRE_NOTEMPTY and PCRE_ANCHORED, and then         again at the same offset with PCRE_NOTEMPTY and PCRE_ANCHORED, and then
1963         if  that  fails by advancing the starting offset (see below) and trying         if that fails by advancing the starting offset (see below)  and  trying
1964         an ordinary match again. There is some code that demonstrates how to do         an ordinary match again. There is some code that demonstrates how to do
1965         this in the pcredemo.c sample program.         this in the pcredemo.c sample program.
1966    
1967           PCRE_NO_UTF8_CHECK           PCRE_NO_UTF8_CHECK
1968    
1969         When PCRE_UTF8 is set at compile time, the validity of the subject as a         When PCRE_UTF8 is set at compile time, the validity of the subject as a
1970         UTF-8 string is automatically checked when pcre_exec() is  subsequently         UTF-8  string is automatically checked when pcre_exec() is subsequently
1971         called.   The  value  of  startoffset is also checked to ensure that it         called.  The value of startoffset is also checked  to  ensure  that  it
1972         points to the start of a UTF-8 character. There is a  discussion  about         points  to  the start of a UTF-8 character. There is a discussion about
1973         the  validity  of  UTF-8 strings in the section on UTF-8 support in the         the validity of UTF-8 strings in the section on UTF-8  support  in  the
1974         main pcre page. If  an  invalid  UTF-8  sequence  of  bytes  is  found,         main  pcre  page.  If  an  invalid  UTF-8  sequence  of bytes is found,
1975         pcre_exec()  returns  the error PCRE_ERROR_BADUTF8. If startoffset con-         pcre_exec() returns the error PCRE_ERROR_BADUTF8. If  startoffset  con-
1976         tains an invalid value, PCRE_ERROR_BADUTF8_OFFSET is returned.         tains an invalid value, PCRE_ERROR_BADUTF8_OFFSET is returned.
1977    
1978         If you already know that your subject is valid, and you  want  to  skip         If  you  already  know that your subject is valid, and you want to skip
1979         these    checks    for   performance   reasons,   you   can   set   the         these   checks   for   performance   reasons,   you   can    set    the
1980         PCRE_NO_UTF8_CHECK option when calling pcre_exec(). You might  want  to         PCRE_NO_UTF8_CHECK  option  when calling pcre_exec(). You might want to
1981         do  this  for the second and subsequent calls to pcre_exec() if you are         do this for the second and subsequent calls to pcre_exec() if  you  are
1982         making repeated calls to find all  the  matches  in  a  single  subject         making  repeated  calls  to  find  all  the matches in a single subject
1983         string.  However,  you  should  be  sure  that the value of startoffset         string. However, you should be  sure  that  the  value  of  startoffset
1984         points to the start of a UTF-8 character.  When  PCRE_NO_UTF8_CHECK  is         points  to  the  start of a UTF-8 character. When PCRE_NO_UTF8_CHECK is
1985         set,  the  effect of passing an invalid UTF-8 string as a subject, or a         set, the effect of passing an invalid UTF-8 string as a subject,  or  a
1986         value of startoffset that does not point to the start of a UTF-8  char-         value  of startoffset that does not point to the start of a UTF-8 char-
1987         acter, is undefined. Your program may crash.         acter, is undefined. Your program may crash.
1988    
1989           PCRE_PARTIAL           PCRE_PARTIAL
1990    
1991         This  option  turns  on  the  partial  matching feature. If the subject         This option turns on the  partial  matching  feature.  If  the  subject
1992         string fails to match the pattern, but at some point during the  match-         string  fails to match the pattern, but at some point during the match-
1993         ing  process  the  end of the subject was reached (that is, the subject         ing process the end of the subject was reached (that  is,  the  subject
1994         partially matches the pattern and the failure to  match  occurred  only         partially  matches  the  pattern and the failure to match occurred only
1995         because  there were not enough subject characters), pcre_exec() returns         because there were not enough subject characters), pcre_exec()  returns
1996         PCRE_ERROR_PARTIAL instead of PCRE_ERROR_NOMATCH. When PCRE_PARTIAL  is         PCRE_ERROR_PARTIAL  instead of PCRE_ERROR_NOMATCH. When PCRE_PARTIAL is
1997         used,  there  are restrictions on what may appear in the pattern. These         used, there are restrictions on what may appear in the  pattern.  These
1998         are discussed in the pcrepartial documentation.         are discussed in the pcrepartial documentation.
1999    
2000     The string to be matched by pcre_exec()     The string to be matched by pcre_exec()
2001    
2002         The subject string is passed to pcre_exec() as a pointer in subject,  a         The  subject string is passed to pcre_exec() as a pointer in subject, a
2003         length  in  length, and a starting byte offset in startoffset. In UTF-8         length in length, and a starting byte offset in startoffset.  In  UTF-8
2004         mode, the byte offset must point to the start  of  a  UTF-8  character.         mode,  the  byte  offset  must point to the start of a UTF-8 character.
2005         Unlike  the  pattern string, the subject may contain binary zero bytes.         Unlike the pattern string, the subject may contain binary  zero  bytes.
2006         When the starting offset is zero, the search for a match starts at  the         When  the starting offset is zero, the search for a match starts at the
2007         beginning of the subject, and this is by far the most common case.         beginning of the subject, and this is by far the most common case.
2008    
2009         A  non-zero  starting offset is useful when searching for another match         A non-zero starting offset is useful when searching for  another  match
2010         in the same subject by calling pcre_exec() again after a previous  suc-         in  the same subject by calling pcre_exec() again after a previous suc-
2011         cess.   Setting  startoffset differs from just passing over a shortened         cess.  Setting startoffset differs from just passing over  a  shortened
2012         string and setting PCRE_NOTBOL in the case of  a  pattern  that  begins         string  and  setting  PCRE_NOTBOL  in the case of a pattern that begins
2013         with any kind of lookbehind. For example, consider the pattern         with any kind of lookbehind. For example, consider the pattern
2014    
2015           \Biss\B           \Biss\B
2016    
2017         which  finds  occurrences  of "iss" in the middle of words. (\B matches         which finds occurrences of "iss" in the middle of  words.  (\B  matches
2018         only if the current position in the subject is not  a  word  boundary.)         only  if  the  current position in the subject is not a word boundary.)
2019         When  applied  to the string "Mississipi" the first call to pcre_exec()         When applied to the string "Mississipi" the first call  to  pcre_exec()
2020         finds the first occurrence. If pcre_exec() is called  again  with  just         finds  the  first  occurrence. If pcre_exec() is called again with just
2021         the  remainder  of  the  subject,  namely  "issipi", it does not match,         the remainder of the subject,  namely  "issipi",  it  does  not  match,
2022         because \B is always false at the start of the subject, which is deemed         because \B is always false at the start of the subject, which is deemed
2023         to  be  a  word  boundary. However, if pcre_exec() is passed the entire         to be a word boundary. However, if pcre_exec()  is  passed  the  entire
2024         string again, but with startoffset set to 4, it finds the second occur-         string again, but with startoffset set to 4, it finds the second occur-
2025         rence  of "iss" because it is able to look behind the starting point to         rence of "iss" because it is able to look behind the starting point  to
2026         discover that it is preceded by a letter.         discover that it is preceded by a letter.
2027    
2028         If a non-zero starting offset is passed when the pattern  is  anchored,         If  a  non-zero starting offset is passed when the pattern is anchored,
2029         one attempt to match at the given offset is made. This can only succeed         one attempt to match at the given offset is made. This can only succeed
2030         if the pattern does not require the match to be at  the  start  of  the         if  the  pattern  does  not require the match to be at the start of the
2031         subject.         subject.
2032    
2033     How pcre_exec() returns captured substrings     How pcre_exec() returns captured substrings
2034    
2035         In  general, a pattern matches a certain portion of the subject, and in         In general, a pattern matches a certain portion of the subject, and  in
2036         addition, further substrings from the subject  may  be  picked  out  by         addition,  further  substrings  from  the  subject may be picked out by
2037         parts  of  the  pattern.  Following the usage in Jeffrey Friedl's book,         parts of the pattern. Following the usage  in  Jeffrey  Friedl's  book,
2038         this is called "capturing" in what follows, and the  phrase  "capturing         this  is  called "capturing" in what follows, and the phrase "capturing
2039         subpattern"  is  used for a fragment of a pattern that picks out a sub-         subpattern" is used for a fragment of a pattern that picks out  a  sub-
2040         string. PCRE supports several other kinds of  parenthesized  subpattern         string.  PCRE  supports several other kinds of parenthesized subpattern
2041         that do not cause substrings to be captured.         that do not cause substrings to be captured.
2042    
2043         Captured  substrings are returned to the caller via a vector of integer         Captured substrings are returned to the caller via a vector of  integer
2044         offsets whose address is passed in ovector. The number of  elements  in         offsets  whose  address is passed in ovector. The number of elements in
2045         the  vector is passed in ovecsize, which must be a non-negative number.         the vector is passed in ovecsize, which must be a non-negative  number.
2046         Note: this argument is NOT the size of ovector in bytes.         Note: this argument is NOT the size of ovector in bytes.
2047    
2048         The first two-thirds of the vector is used to pass back  captured  sub-         The  first  two-thirds of the vector is used to pass back captured sub-
2049         strings,  each  substring using a pair of integers. The remaining third         strings, each substring using a pair of integers. The  remaining  third
2050         of the vector is used as workspace by pcre_exec() while  matching  cap-         of  the  vector is used as workspace by pcre_exec() while matching cap-
2051         turing  subpatterns, and is not available for passing back information.         turing subpatterns, and is not available for passing back  information.
2052         The length passed in ovecsize should always be a multiple of three.  If         The  length passed in ovecsize should always be a multiple of three. If
2053         it is not, it is rounded down.         it is not, it is rounded down.
2054    
2055         When  a  match  is successful, information about captured substrings is         When a match is successful, information about  captured  substrings  is
2056         returned in pairs of integers, starting at the  beginning  of  ovector,         returned  in  pairs  of integers, starting at the beginning of ovector,
2057         and  continuing  up  to two-thirds of its length at the most. The first         and continuing up to two-thirds of its length at the  most.  The  first
2058         element of a pair is set to the offset of the first character in a sub-         element of a pair is set to the offset of the first character in a sub-
2059         string,  and  the  second  is  set to the offset of the first character         string, and the second is set to the  offset  of  the  first  character
2060         after the end of a substring. The  first  pair,  ovector[0]  and  ovec-         after  the  end  of  a  substring. The first pair, ovector[0] and ovec-
2061         tor[1],  identify  the  portion  of  the  subject string matched by the         tor[1], identify the portion of  the  subject  string  matched  by  the
2062         entire pattern. The next pair is used for the first  capturing  subpat-         entire  pattern.  The next pair is used for the first capturing subpat-
2063         tern, and so on. The value returned by pcre_exec() is one more than the         tern, and so on. The value returned by pcre_exec() is one more than the
2064         highest numbered pair that has been set. For example, if two substrings         highest numbered pair that has been set. For example, if two substrings
2065         have  been captured, the returned value is 3. If there are no capturing         have been captured, the returned value is 3. If there are no  capturing
2066         subpatterns, the return value from a successful match is 1,  indicating         subpatterns,  the return value from a successful match is 1, indicating
2067         that just the first pair of offsets has been set.         that just the first pair of offsets has been set.
2068    
2069         If a capturing subpattern is matched repeatedly, it is the last portion         If a capturing subpattern is matched repeatedly, it is the last portion
2070         of the string that it matched that is returned.         of the string that it matched that is returned.
2071    
2072         If the vector is too small to hold all the captured substring  offsets,         If  the vector is too small to hold all the captured substring offsets,
2073         it is used as far as possible (up to two-thirds of its length), and the         it is used as far as possible (up to two-thirds of its length), and the
2074         function returns a value of zero. In particular, if the substring  off-         function  returns a value of zero. In particular, if the substring off-
2075         sets are not of interest, pcre_exec() may be called with ovector passed         sets are not of interest, pcre_exec() may be called with ovector passed
2076         as NULL and ovecsize as zero. However, if  the  pattern  contains  back         as  NULL  and  ovecsize  as zero. However, if the pattern contains back
2077         references  and  the  ovector is not big enough to remember the related         references and the ovector is not big enough to  remember  the  related
2078         substrings, PCRE has to get additional memory for use during  matching.         substrings,  PCRE has to get additional memory for use during matching.
2079         Thus it is usually advisable to supply an ovector.         Thus it is usually advisable to supply an ovector.
2080    
2081         The  pcre_info()  function  can  be used to find out how many capturing         The pcre_info() function can be used to find  out  how  many  capturing
2082         subpatterns there are in a compiled  pattern.  The  smallest  size  for         subpatterns  there  are  in  a  compiled pattern. The smallest size for
2083         ovector  that  will allow for n captured substrings, in addition to the         ovector that will allow for n captured substrings, in addition  to  the
2084         offsets of the substring matched by the whole pattern, is (n+1)*3.         offsets of the substring matched by the whole pattern, is (n+1)*3.
2085    
2086         It is possible for capturing subpattern number n+1 to match  some  part         It  is  possible for capturing subpattern number n+1 to match some part
2087         of the subject when subpattern n has not been used at all. For example,         of the subject when subpattern n has not been used at all. For example,
2088         if the string "abc" is matched  against  the  pattern  (a|(z))(bc)  the         if  the  string  "abc"  is  matched against the pattern (a|(z))(bc) the
2089         return from the function is 4, and subpatterns 1 and 3 are matched, but         return from the function is 4, and subpatterns 1 and 3 are matched, but
2090         2 is not. When this happens, both values in  the  offset  pairs  corre-         2  is  not.  When  this happens, both values in the offset pairs corre-
2091         sponding to unused subpatterns are set to -1.         sponding to unused subpatterns are set to -1.
2092    
2093         Offset  values  that correspond to unused subpatterns at the end of the         Offset values that correspond to unused subpatterns at the end  of  the
2094         expression are also set to -1. For example,  if  the  string  "abc"  is         expression  are  also  set  to  -1. For example, if the string "abc" is
2095         matched  against the pattern (abc)(x(yz)?)? subpatterns 2 and 3 are not         matched against the pattern (abc)(x(yz)?)? subpatterns 2 and 3 are  not
2096         matched. The return from the function is 2, because  the  highest  used         matched.  The  return  from the function is 2, because the highest used
2097         capturing subpattern number is 1. However, you can refer to the offsets         capturing subpattern number is 1. However, you can refer to the offsets
2098         for the second and third capturing subpatterns if  you  wish  (assuming         for  the  second  and third capturing subpatterns if you wish (assuming
2099         the vector is large enough, of course).         the vector is large enough, of course).
2100    
2101         Some  convenience  functions  are  provided for extracting the captured         Some convenience functions are provided  for  extracting  the  captured
2102         substrings as separate strings. These are described below.         substrings as separate strings. These are described below.
2103    
2104     Error return values from pcre_exec()     Error return values from pcre_exec()
2105    
2106         If pcre_exec() fails, it returns a negative number. The  following  are         If  pcre_exec()  fails, it returns a negative number. The following are
2107         defined in the header file:         defined in the header file:
2108    
2109           PCRE_ERROR_NOMATCH        (-1)           PCRE_ERROR_NOMATCH        (-1)
# Line 2079  MATCHING A PATTERN: THE TRADITIONAL FUNC Line 2112  MATCHING A PATTERN: THE TRADITIONAL FUNC
2112    
2113           PCRE_ERROR_NULL           (-2)           PCRE_ERROR_NULL           (-2)
2114    
2115         Either  code  or  subject  was  passed as NULL, or ovector was NULL and         Either code or subject was passed as NULL,  or  ovector  was  NULL  and
2116         ovecsize was not zero.         ovecsize was not zero.
2117    
2118           PCRE_ERROR_BADOPTION      (-3)           PCRE_ERROR_BADOPTION      (-3)
# Line 2088  MATCHING A PATTERN: THE TRADITIONAL FUNC Line 2121  MATCHING A PATTERN: THE TRADITIONAL FUNC
2121    
2122           PCRE_ERROR_BADMAGIC       (-4)           PCRE_ERROR_BADMAGIC       (-4)
2123    
2124         PCRE stores a 4-byte "magic number" at the start of the compiled  code,         PCRE  stores a 4-byte "magic number" at the start of the compiled code,
2125         to catch the case when it is passed a junk pointer and to detect when a         to catch the case when it is passed a junk pointer and to detect when a
2126         pattern that was compiled in an environment of one endianness is run in         pattern that was compiled in an environment of one endianness is run in
2127         an  environment  with the other endianness. This is the error that PCRE         an environment with the other endianness. This is the error  that  PCRE
2128         gives when the magic number is not present.         gives when the magic number is not present.
2129    
2130           PCRE_ERROR_UNKNOWN_OPCODE (-5)           PCRE_ERROR_UNKNOWN_OPCODE (-5)
2131    
2132         While running the pattern match, an unknown item was encountered in the         While running the pattern match, an unknown item was encountered in the
2133         compiled  pattern.  This  error  could be caused by a bug in PCRE or by         compiled pattern. This error could be caused by a bug  in  PCRE  or  by
2134         overwriting of the compiled pattern.         overwriting of the compiled pattern.
2135    
2136           PCRE_ERROR_NOMEMORY       (-6)           PCRE_ERROR_NOMEMORY       (-6)
2137    
2138         If a pattern contains back references, but the ovector that  is  passed         If  a  pattern contains back references, but the ovector that is passed
2139         to pcre_exec() is not big enough to remember the referenced substrings,         to pcre_exec() is not big enough to remember the referenced substrings,
2140         PCRE gets a block of memory at the start of matching to  use  for  this         PCRE  gets  a  block of memory at the start of matching to use for this
2141         purpose.  If the call via pcre_malloc() fails, this error is given. The         purpose. If the call via pcre_malloc() fails, this error is given.  The
2142         memory is automatically freed at the end of matching.         memory is automatically freed at the end of matching.
2143    
2144           PCRE_ERROR_NOSUBSTRING    (-7)           PCRE_ERROR_NOSUBSTRING    (-7)
2145    
2146         This error is used by the pcre_copy_substring(),  pcre_get_substring(),         This  error is used by the pcre_copy_substring(), pcre_get_substring(),
2147         and  pcre_get_substring_list()  functions  (see  below).  It  is  never         and  pcre_get_substring_list()  functions  (see  below).  It  is  never
2148         returned by pcre_exec().         returned by pcre_exec().
2149    
2150           PCRE_ERROR_MATCHLIMIT     (-8)           PCRE_ERROR_MATCHLIMIT     (-8)
2151    
2152         The backtracking limit, as specified by  the  match_limit  field  in  a         The  backtracking  limit,  as  specified  by the match_limit field in a
2153         pcre_extra  structure  (or  defaulted) was reached. See the description         pcre_extra structure (or defaulted) was reached.  See  the  description
2154         above.         above.
2155    
2156           PCRE_ERROR_CALLOUT        (-9)           PCRE_ERROR_CALLOUT        (-9)
2157    
2158         This error is never generated by pcre_exec() itself. It is provided for         This error is never generated by pcre_exec() itself. It is provided for
2159         use  by  callout functions that want to yield a distinctive error code.         use by callout functions that want to yield a distinctive  error  code.
2160         See the pcrecallout documentation for details.         See the pcrecallout documentation for details.
2161    
2162           PCRE_ERROR_BADUTF8        (-10)           PCRE_ERROR_BADUTF8        (-10)
2163    
2164         A string that contains an invalid UTF-8 byte sequence was passed  as  a         A  string  that contains an invalid UTF-8 byte sequence was passed as a
2165         subject.         subject.
2166    
2167           PCRE_ERROR_BADUTF8_OFFSET (-11)           PCRE_ERROR_BADUTF8_OFFSET (-11)
2168    
2169         The UTF-8 byte sequence that was passed as a subject was valid, but the         The UTF-8 byte sequence that was passed as a subject was valid, but the
2170         value of startoffset did not point to the beginning of a UTF-8  charac-         value  of startoffset did not point to the beginning of a UTF-8 charac-
2171         ter.         ter.
2172    
2173           PCRE_ERROR_PARTIAL        (-12)           PCRE_ERROR_PARTIAL        (-12)
2174    
2175         The  subject  string did not match, but it did match partially. See the         The subject string did not match, but it did match partially.  See  the
2176         pcrepartial documentation for details of partial matching.         pcrepartial documentation for details of partial matching.
2177    
2178           PCRE_ERROR_BADPARTIAL     (-13)           PCRE_ERROR_BADPARTIAL     (-13)
2179    
2180         The PCRE_PARTIAL option was used with  a  compiled  pattern  containing         The  PCRE_PARTIAL  option  was  used with a compiled pattern containing
2181         items  that are not supported for partial matching. See the pcrepartial         items that are not supported for partial matching. See the  pcrepartial
2182         documentation for details of partial matching.         documentation for details of partial matching.
2183    
2184           PCRE_ERROR_INTERNAL       (-14)           PCRE_ERROR_INTERNAL       (-14)
2185    
2186         An unexpected internal error has occurred. This error could  be  caused         An  unexpected  internal error has occurred. This error could be caused
2187         by a bug in PCRE or by overwriting of the compiled pattern.         by a bug in PCRE or by overwriting of the compiled pattern.
2188    
2189           PCRE_ERROR_BADCOUNT       (-15)           PCRE_ERROR_BADCOUNT       (-15)
2190    
2191         This  error is given if the value of the ovecsize argument is negative.         This error is given if the value of the ovecsize argument is  negative.
2192    
2193           PCRE_ERROR_RECURSIONLIMIT (-21)           PCRE_ERROR_RECURSIONLIMIT (-21)
2194    
2195         The internal recursion limit, as specified by the match_limit_recursion         The internal recursion limit, as specified by the match_limit_recursion
2196         field  in  a  pcre_extra  structure (or defaulted) was reached. See the         field in a pcre_extra structure (or defaulted)  was  reached.  See  the
2197         description above.         description above.
2198    
2199           PCRE_ERROR_BADNEWLINE     (-23)           PCRE_ERROR_BADNEWLINE     (-23)
# Line 2183  EXTRACTING CAPTURED SUBSTRINGS BY NUMBER Line 2216  EXTRACTING CAPTURED SUBSTRINGS BY NUMBER
2216         int pcre_get_substring_list(const char *subject,         int pcre_get_substring_list(const char *subject,
2217              int *ovector, int stringcount, const char ***listptr);              int *ovector, int stringcount, const char ***listptr);
2218    
2219         Captured substrings can be  accessed  directly  by  using  the  offsets         Captured  substrings  can  be  accessed  directly  by using the offsets
2220         returned  by  pcre_exec()  in  ovector.  For convenience, the functions         returned by pcre_exec() in  ovector.  For  convenience,  the  functions
2221         pcre_copy_substring(),    pcre_get_substring(),    and    pcre_get_sub-         pcre_copy_substring(),    pcre_get_substring(),    and    pcre_get_sub-
2222         string_list()  are  provided for extracting captured substrings as new,         string_list() are provided for extracting captured substrings  as  new,
2223         separate, zero-terminated strings. These functions identify  substrings         separate,  zero-terminated strings. These functions identify substrings
2224         by  number.  The  next section describes functions for extracting named         by number. The next section describes functions  for  extracting  named
2225         substrings.         substrings.
2226    
2227         A substring that contains a binary zero is correctly extracted and  has         A  substring that contains a binary zero is correctly extracted and has
2228         a  further zero added on the end, but the result is not, of course, a C         a further zero added on the end, but the result is not, of course, a  C
2229         string.  However, you can process such a string  by  referring  to  the         string.   However,  you  can  process such a string by referring to the
2230         length  that  is  returned  by  pcre_copy_substring() and pcre_get_sub-         length that is  returned  by  pcre_copy_substring()  and  pcre_get_sub-
2231         string().  Unfortunately, the interface to pcre_get_substring_list() is         string().  Unfortunately, the interface to pcre_get_substring_list() is
2232         not  adequate for handling strings containing binary zeros, because the         not adequate for handling strings containing binary zeros, because  the
2233         end of the final string is not independently indicated.         end of the final string is not independently indicated.
2234    
2235         The first three arguments are the same for all  three  of  these  func-         The  first  three  arguments  are the same for all three of these func-
2236         tions:  subject  is  the subject string that has just been successfully         tions: subject is the subject string that has  just  been  successfully
2237         matched, ovector is a pointer to the vector of integer offsets that was         matched, ovector is a pointer to the vector of integer offsets that was
2238         passed to pcre_exec(), and stringcount is the number of substrings that         passed to pcre_exec(), and stringcount is the number of substrings that
2239         were captured by the match, including the substring  that  matched  the         were  captured  by  the match, including the substring that matched the
2240         entire regular expression. This is the value returned by pcre_exec() if         entire regular expression. This is the value returned by pcre_exec() if
2241         it is greater than zero. If pcre_exec() returned zero, indicating  that         it  is greater than zero. If pcre_exec() returned zero, indicating that
2242         it  ran out of space in ovector, the value passed as stringcount should         it ran out of space in ovector, the value passed as stringcount  should
2243         be the number of elements in the vector divided by three.         be the number of elements in the vector divided by three.
2244    
2245         The functions pcre_copy_substring() and pcre_get_substring() extract  a         The  functions pcre_copy_substring() and pcre_get_substring() extract a
2246         single  substring,  whose  number  is given as stringnumber. A value of         single substring, whose number is given as  stringnumber.  A  value  of
2247         zero extracts the substring that matched the  entire  pattern,  whereas         zero  extracts  the  substring that matched the entire pattern, whereas
2248         higher  values  extract  the  captured  substrings.  For pcre_copy_sub-         higher values  extract  the  captured  substrings.  For  pcre_copy_sub-
2249         string(), the string is placed in buffer,  whose  length  is  given  by         string(),  the  string  is  placed  in buffer, whose length is given by
2250         buffersize,  while  for  pcre_get_substring()  a new block of memory is         buffersize, while for pcre_get_substring() a new  block  of  memory  is
2251         obtained via pcre_malloc, and its address is  returned  via  stringptr.         obtained  via  pcre_malloc,  and its address is returned via stringptr.
2252         The  yield  of  the function is the length of the string, not including         The yield of the function is the length of the  string,  not  including
2253         the terminating zero, or one of these error codes:         the terminating zero, or one of these error codes:
2254    
2255           PCRE_ERROR_NOMEMORY       (-6)           PCRE_ERROR_NOMEMORY       (-6)
2256    
2257         The buffer was too small for pcre_copy_substring(), or the  attempt  to         The  buffer  was too small for pcre_copy_substring(), or the attempt to
2258         get memory failed for pcre_get_substring().         get memory failed for pcre_get_substring().
2259    
2260           PCRE_ERROR_NOSUBSTRING    (-7)           PCRE_ERROR_NOSUBSTRING    (-7)
2261    
2262         There is no substring whose number is stringnumber.         There is no substring whose number is stringnumber.
2263    
2264         The  pcre_get_substring_list()  function  extracts  all  available sub-         The pcre_get_substring_list()  function  extracts  all  available  sub-
2265         strings and builds a list of pointers to them. All this is  done  in  a         strings  and  builds  a list of pointers to them. All this is done in a
2266         single block of memory that is obtained via pcre_malloc. The address of         single block of memory that is obtained via pcre_malloc. The address of
2267         the memory block is returned via listptr, which is also  the  start  of         the  memory  block  is returned via listptr, which is also the start of
2268         the  list  of  string pointers. The end of the list is marked by a NULL         the list of string pointers. The end of the list is marked  by  a  NULL
2269         pointer. The yield of the function is zero if all  went  well,  or  the         pointer.  The  yield  of  the function is zero if all went well, or the
2270         error code         error code
2271    
2272           PCRE_ERROR_NOMEMORY       (-6)           PCRE_ERROR_NOMEMORY       (-6)
2273    
2274         if the attempt to get the memory block failed.         if the attempt to get the memory block failed.
2275    
2276         When  any of these functions encounter a substring that is unset, which         When any of these functions encounter a substring that is unset,  which
2277         can happen when capturing subpattern number n+1 matches  some  part  of         can  happen  when  capturing subpattern number n+1 matches some part of
2278         the  subject, but subpattern n has not been used at all, they return an         the subject, but subpattern n has not been used at all, they return  an
2279         empty string. This can be distinguished from a genuine zero-length sub-         empty string. This can be distinguished from a genuine zero-length sub-
2280         string  by inspecting the appropriate offset in ovector, which is nega-         string by inspecting the appropriate offset in ovector, which is  nega-
2281         tive for unset substrings.         tive for unset substrings.
2282    
2283         The two convenience functions pcre_free_substring() and  pcre_free_sub-         The  two convenience functions pcre_free_substring() and pcre_free_sub-
2284         string_list()  can  be  used  to free the memory returned by a previous         string_list() can be used to free the memory  returned  by  a  previous
2285         call  of  pcre_get_substring()  or  pcre_get_substring_list(),  respec-         call  of  pcre_get_substring()  or  pcre_get_substring_list(),  respec-
2286         tively.  They  do  nothing  more  than  call the function pointed to by         tively. They do nothing more than  call  the  function  pointed  to  by
2287         pcre_free, which of course could be called directly from a  C  program.         pcre_free,  which  of course could be called directly from a C program.
2288         However,  PCRE is used in some situations where it is linked via a spe-         However, PCRE is used in some situations where it is linked via a  spe-
2289         cial  interface  to  another  programming  language  that  cannot   use         cial   interface  to  another  programming  language  that  cannot  use
2290         pcre_free  directly;  it is for these cases that the functions are pro-         pcre_free directly; it is for these cases that the functions  are  pro-
2291         vided.         vided.
2292    
2293    
# Line 2273  EXTRACTING CAPTURED SUBSTRINGS BY NAME Line 2306  EXTRACTING CAPTURED SUBSTRINGS BY NAME
2306              int stringcount, const char *stringname,              int stringcount, const char *stringname,
2307              const char **stringptr);              const char **stringptr);
2308    
2309         To extract a substring by name, you first have to find associated  num-         To  extract a substring by name, you first have to find associated num-
2310         ber.  For example, for this pattern         ber.  For example, for this pattern
2311    
2312           (a+)b(?<xxx>\d+)...           (a+)b(?<xxx>\d+)...
# Line 2282  EXTRACTING CAPTURED SUBSTRINGS BY NAME Line 2315  EXTRACTING CAPTURED SUBSTRINGS BY NAME
2315         be unique (PCRE_DUPNAMES was not set), you can find the number from the         be unique (PCRE_DUPNAMES was not set), you can find the number from the
2316         name by calling pcre_get_stringnumber(). The first argument is the com-         name by calling pcre_get_stringnumber(). The first argument is the com-
2317         piled pattern, and the second is the name. The yield of the function is         piled pattern, and the second is the name. The yield of the function is
2318         the  subpattern  number,  or PCRE_ERROR_NOSUBSTRING (-7) if there is no         the subpattern number, or PCRE_ERROR_NOSUBSTRING (-7) if  there  is  no
2319         subpattern of that name.         subpattern of that name.
2320    
2321         Given the number, you can extract the substring directly, or use one of         Given the number, you can extract the substring directly, or use one of
2322         the functions described in the previous section. For convenience, there         the functions described in the previous section. For convenience, there
2323         are also two functions that do the whole job.         are also two functions that do the whole job.
2324    
2325         Most   of   the   arguments    of    pcre_copy_named_substring()    and         Most    of    the    arguments   of   pcre_copy_named_substring()   and
2326         pcre_get_named_substring()  are  the  same  as  those for the similarly         pcre_get_named_substring() are the same  as  those  for  the  similarly
2327         named functions that extract by number. As these are described  in  the         named  functions  that extract by number. As these are described in the
2328         previous  section,  they  are not re-described here. There are just two         previous section, they are not re-described here. There  are  just  two
2329         differences:         differences:
2330    
2331         First, instead of a substring number, a substring name is  given.  Sec-         First,  instead  of a substring number, a substring name is given. Sec-
2332         ond, there is an extra argument, given at the start, which is a pointer         ond, there is an extra argument, given at the start, which is a pointer
2333         to the compiled pattern. This is needed in order to gain access to  the         to  the compiled pattern. This is needed in order to gain access to the
2334         name-to-number translation table.         name-to-number translation table.
2335    
2336         These  functions call pcre_get_stringnumber(), and if it succeeds, they         These functions call pcre_get_stringnumber(), and if it succeeds,  they
2337         then call pcre_copy_substring() or pcre_get_substring(),  as  appropri-         then  call  pcre_copy_substring() or pcre_get_substring(), as appropri-
2338         ate.  NOTE:  If PCRE_DUPNAMES is set and there are duplicate names, the         ate. NOTE: If PCRE_DUPNAMES is set and there are duplicate  names,  the
2339         behaviour may not be what you want (see the next section).         behaviour may not be what you want (see the next section).
2340    
2341    
# Line 2311  DUPLICATE SUBPATTERN NAMES Line 2344  DUPLICATE SUBPATTERN NAMES
2344         int pcre_get_stringtable_entries(const pcre *code,         int pcre_get_stringtable_entries(const pcre *code,
2345              const char *name, char **first, char **last);              const char *name, char **first, char **last);
2346    
2347         When a pattern is compiled with the  PCRE_DUPNAMES  option,  names  for         When  a  pattern  is  compiled with the PCRE_DUPNAMES option, names for
2348         subpatterns  are  not  required  to  be unique. Normally, patterns with         subpatterns are not required to  be  unique.  Normally,  patterns  with
2349         duplicate names are such that in any one match, only one of  the  named         duplicate  names  are such that in any one match, only one of the named
2350         subpatterns  participates. An example is shown in the pcrepattern docu-         subpatterns participates. An example is shown in the pcrepattern  docu-
2351         mentation.         mentation.
2352    
2353         When   duplicates   are   present,   pcre_copy_named_substring()    and         When    duplicates   are   present,   pcre_copy_named_substring()   and
2354         pcre_get_named_substring()  return the first substring corresponding to         pcre_get_named_substring() return the first substring corresponding  to
2355         the given name that is set. If  none  are  set,  PCRE_ERROR_NOSUBSTRING         the  given  name  that  is set. If none are set, PCRE_ERROR_NOSUBSTRING
2356         (-7)  is  returned;  no  data  is returned. The pcre_get_stringnumber()         (-7) is returned; no  data  is  returned.  The  pcre_get_stringnumber()
2357         function returns one of the numbers that are associated with the  name,         function  returns one of the numbers that are associated with the name,
2358         but it is not defined which it is.         but it is not defined which it is.
2359    
2360         If  you want to get full details of all captured substrings for a given         If you want to get full details of all captured substrings for a  given
2361         name, you must use  the  pcre_get_stringtable_entries()  function.  The         name,  you  must  use  the pcre_get_stringtable_entries() function. The
2362         first argument is the compiled pattern, and the second is the name. The         first argument is the compiled pattern, and the second is the name. The
2363         third and fourth are pointers to variables which  are  updated  by  the         third  and  fourth  are  pointers to variables which are updated by the
2364         function. After it has run, they point to the first and last entries in         function. After it has run, they point to the first and last entries in
2365         the name-to-number table  for  the  given  name.  The  function  itself         the  name-to-number  table  for  the  given  name.  The function itself
2366         returns  the  length  of  each entry, or PCRE_ERROR_NOSUBSTRING (-7) if         returns the length of each entry,  or  PCRE_ERROR_NOSUBSTRING  (-7)  if
2367         there are none. The format of the table is described above in the  sec-         there  are none. The format of the table is described above in the sec-
2368         tion  entitled  Information  about  a  pattern.  Given all the relevant         tion entitled Information about a  pattern.   Given  all  the  relevant
2369         entries for the name, you can extract each of their numbers, and  hence         entries  for the name, you can extract each of their numbers, and hence
2370         the captured data, if any.         the captured data, if any.
2371    
2372    
2373  FINDING ALL POSSIBLE MATCHES  FINDING ALL POSSIBLE MATCHES
2374    
2375         The  traditional  matching  function  uses a similar algorithm to Perl,         The traditional matching function uses a  similar  algorithm  to  Perl,
2376         which stops when it finds the first match, starting at a given point in         which stops when it finds the first match, starting at a given point in
2377         the  subject.  If you want to find all possible matches, or the longest         the subject. If you want to find all possible matches, or  the  longest
2378         possible match, consider using the alternative matching  function  (see         possible  match,  consider using the alternative matching function (see
2379         below)  instead.  If you cannot use the alternative function, but still         below) instead. If you cannot use the alternative function,  but  still
2380         need to find all possible matches, you can kludge it up by  making  use         need  to  find all possible matches, you can kludge it up by making use
2381         of the callout facility, which is described in the pcrecallout documen-         of the callout facility, which is described in the pcrecallout documen-
2382         tation.         tation.
2383    
2384         What you have to do is to insert a callout right at the end of the pat-         What you have to do is to insert a callout right at the end of the pat-
2385         tern.   When your callout function is called, extract and save the cur-         tern.  When your callout function is called, extract and save the  cur-
2386         rent matched substring. Then return  1,  which  forces  pcre_exec()  to         rent  matched  substring.  Then  return  1, which forces pcre_exec() to
2387         backtrack  and  try other alternatives. Ultimately, when it runs out of         backtrack and try other alternatives. Ultimately, when it runs  out  of
2388         matches, pcre_exec() will yield PCRE_ERROR_NOMATCH.         matches, pcre_exec() will yield PCRE_ERROR_NOMATCH.
2389    
2390    
# Line 2362  MATCHING A PATTERN: THE ALTERNATIVE FUNC Line 2395  MATCHING A PATTERN: THE ALTERNATIVE FUNC
2395              int options, int *ovector, int ovecsize,              int options, int *ovector, int ovecsize,
2396              int *workspace, int wscount);              int *workspace, int wscount);
2397    
2398         The function pcre_dfa_exec()  is  called  to  match  a  subject  string         The  function  pcre_dfa_exec()  is  called  to  match  a subject string
2399         against  a  compiled pattern, using a matching algorithm that scans the         against a compiled pattern, using a matching algorithm that  scans  the
2400         subject string just once, and does not backtrack.  This  has  different         subject  string  just  once, and does not backtrack. This has different
2401         characteristics  to  the  normal  algorithm, and is not compatible with         characteristics to the normal algorithm, and  is  not  compatible  with
2402         Perl. Some of the features of PCRE patterns are not  supported.  Never-         Perl.  Some  of the features of PCRE patterns are not supported. Never-
2403         theless,  there are times when this kind of matching can be useful. For         theless, there are times when this kind of matching can be useful.  For
2404         a discussion of the two matching algorithms, see the pcrematching docu-         a discussion of the two matching algorithms, see the pcrematching docu-
2405         mentation.         mentation.
2406    
2407         The  arguments  for  the  pcre_dfa_exec()  function are the same as for         The arguments for the pcre_dfa_exec() function  are  the  same  as  for
2408         pcre_exec(), plus two extras. The ovector argument is used in a differ-         pcre_exec(), plus two extras. The ovector argument is used in a differ-
2409         ent  way,  and  this is described below. The other common arguments are         ent way, and this is described below. The other  common  arguments  are
2410         used in the same way as for pcre_exec(), so their  description  is  not         used  in  the  same way as for pcre_exec(), so their description is not
2411         repeated here.         repeated here.
2412    
2413         The  two  additional  arguments provide workspace for the function. The         The two additional arguments provide workspace for  the  function.  The
2414         workspace vector should contain at least 20 elements. It  is  used  for         workspace  vector  should  contain at least 20 elements. It is used for
2415         keeping  track  of  multiple  paths  through  the  pattern  tree.  More         keeping  track  of  multiple  paths  through  the  pattern  tree.  More
2416         workspace will be needed for patterns and subjects where  there  are  a         workspace  will  be  needed for patterns and subjects where there are a
2417         lot of potential matches.         lot of potential matches.
2418    
2419         Here is an example of a simple call to pcre_dfa_exec():         Here is an example of a simple call to pcre_dfa_exec():
# Line 2402  MATCHING A PATTERN: THE ALTERNATIVE FUNC Line 2435  MATCHING A PATTERN: THE ALTERNATIVE FUNC
2435    
2436     Option bits for pcre_dfa_exec()     Option bits for pcre_dfa_exec()
2437    
2438         The  unused  bits  of  the options argument for pcre_dfa_exec() must be         The unused bits of the options argument  for  pcre_dfa_exec()  must  be
2439         zero. The only bits  that  may  be  set  are  PCRE_ANCHORED,  PCRE_NEW-         zero.  The  only  bits  that  may  be  set are PCRE_ANCHORED, PCRE_NEW-
2440         LINE_xxx,  PCRE_NOTBOL, PCRE_NOTEOL, PCRE_NOTEMPTY, PCRE_NO_UTF8_CHECK,         LINE_xxx, PCRE_NOTBOL, PCRE_NOTEOL, PCRE_NOTEMPTY,  PCRE_NO_UTF8_CHECK,
2441         PCRE_PARTIAL, PCRE_DFA_SHORTEST, and PCRE_DFA_RESTART. All but the last         PCRE_PARTIAL, PCRE_DFA_SHORTEST, and PCRE_DFA_RESTART. All but the last
2442         three of these are the same as for pcre_exec(), so their description is         three of these are the same as for pcre_exec(), so their description is
2443         not repeated here.         not repeated here.
2444    
2445           PCRE_PARTIAL           PCRE_PARTIAL
2446    
2447         This has the same general effect as it does for  pcre_exec(),  but  the         This  has  the  same general effect as it does for pcre_exec(), but the
2448         details   are   slightly   different.  When  PCRE_PARTIAL  is  set  for         details  are  slightly  different.  When  PCRE_PARTIAL   is   set   for
2449         pcre_dfa_exec(), the return code PCRE_ERROR_NOMATCH is  converted  into         pcre_dfa_exec(),  the  return code PCRE_ERROR_NOMATCH is converted into
2450         PCRE_ERROR_PARTIAL  if  the  end  of the subject is reached, there have         PCRE_ERROR_PARTIAL if the end of the subject  is  reached,  there  have
2451         been no complete matches, but there is still at least one matching pos-         been no complete matches, but there is still at least one matching pos-
2452         sibility.  The portion of the string that provided the partial match is         sibility. The portion of the string that provided the partial match  is
2453         set as the first matching string.         set as the first matching string.
2454    
2455           PCRE_DFA_SHORTEST           PCRE_DFA_SHORTEST
2456    
2457         Setting the PCRE_DFA_SHORTEST option causes the matching  algorithm  to         Setting  the  PCRE_DFA_SHORTEST option causes the matching algorithm to
2458         stop as soon as it has found one match. Because of the way the alterna-         stop as soon as it has found one match. Because of the way the alterna-
2459         tive algorithm works, this is necessarily the shortest  possible  match         tive  algorithm  works, this is necessarily the shortest possible match
2460         at the first possible matching point in the subject string.         at the first possible matching point in the subject string.
2461    
2462           PCRE_DFA_RESTART           PCRE_DFA_RESTART
2463    
2464         When  pcre_dfa_exec()  is  called  with  the  PCRE_PARTIAL  option, and         When pcre_dfa_exec()  is  called  with  the  PCRE_PARTIAL  option,  and
2465         returns a partial match, it is possible to call it  again,  with  addi-         returns  a  partial  match, it is possible to call it again, with addi-
2466         tional  subject  characters,  and have it continue with the same match.         tional subject characters, and have it continue with  the  same  match.
2467         The PCRE_DFA_RESTART option requests this action; when it is  set,  the         The  PCRE_DFA_RESTART  option requests this action; when it is set, the
2468         workspace  and wscount options must reference the same vector as before         workspace and wscount options must reference the same vector as  before
2469         because data about the match so far is left in  them  after  a  partial         because  data  about  the  match so far is left in them after a partial
2470         match.  There  is  more  discussion of this facility in the pcrepartial         match. There is more discussion of this  facility  in  the  pcrepartial
2471         documentation.         documentation.
2472    
2473     Successful returns from pcre_dfa_exec()     Successful returns from pcre_dfa_exec()
2474    
2475         When pcre_dfa_exec() succeeds, it may have matched more than  one  sub-         When  pcre_dfa_exec()  succeeds, it may have matched more than one sub-
2476         string in the subject. Note, however, that all the matches from one run         string in the subject. Note, however, that all the matches from one run
2477         of the function start at the same point in  the  subject.  The  shorter         of  the  function  start  at the same point in the subject. The shorter
2478         matches  are all initial substrings of the longer matches. For example,         matches are all initial substrings of the longer matches. For  example,
2479         if the pattern         if the pattern
2480    
2481           <.*>           <.*>
# Line 2457  MATCHING A PATTERN: THE ALTERNATIVE FUNC Line 2490  MATCHING A PATTERN: THE ALTERNATIVE FUNC
2490           <something> <something else>           <something> <something else>
2491           <something> <something else> <something further>           <something> <something else> <something further>
2492    
2493         On success, the yield of the function is a number  greater  than  zero,         On  success,  the  yield of the function is a number greater than zero,
2494         which  is  the  number of matched substrings. The substrings themselves         which is the number of matched substrings.  The  substrings  themselves
2495         are returned in ovector. Each string uses two elements;  the  first  is         are  returned  in  ovector. Each string uses two elements; the first is
2496         the  offset  to  the start, and the second is the offset to the end. In         the offset to the start, and the second is the offset to  the  end.  In
2497         fact, all the strings have the same start  offset.  (Space  could  have         fact,  all  the  strings  have the same start offset. (Space could have
2498         been  saved by giving this only once, but it was decided to retain some         been saved by giving this only once, but it was decided to retain  some
2499         compatibility with the way pcre_exec() returns data,  even  though  the         compatibility  with  the  way pcre_exec() returns data, even though the
2500         meaning of the strings is different.)         meaning of the strings is different.)
2501    
2502         The strings are returned in reverse order of length; that is, the long-         The strings are returned in reverse order of length; that is, the long-
2503         est matching string is given first. If there were too many  matches  to         est  matching  string is given first. If there were too many matches to
2504         fit  into ovector, the yield of the function is zero, and the vector is         fit into ovector, the yield of the function is zero, and the vector  is
2505         filled with the longest matches.         filled with the longest matches.
2506    
2507     Error returns from pcre_dfa_exec()     Error returns from pcre_dfa_exec()
2508    
2509         The pcre_dfa_exec() function returns a negative number when  it  fails.         The  pcre_dfa_exec()  function returns a negative number when it fails.
2510         Many  of  the  errors  are  the  same as for pcre_exec(), and these are         Many of the errors are the same  as  for  pcre_exec(),  and  these  are
2511         described above.  There are in addition the following errors  that  are         described  above.   There are in addition the following errors that are
2512         specific to pcre_dfa_exec():         specific to pcre_dfa_exec():
2513    
2514           PCRE_ERROR_DFA_UITEM      (-16)           PCRE_ERROR_DFA_UITEM      (-16)
2515    
2516         This  return is given if pcre_dfa_exec() encounters an item in the pat-         This return is given if pcre_dfa_exec() encounters an item in the  pat-
2517         tern that it does not support, for instance, the use of \C  or  a  back         tern  that  it  does not support, for instance, the use of \C or a back
2518         reference.         reference.
2519    
2520           PCRE_ERROR_DFA_UCOND      (-17)           PCRE_ERROR_DFA_UCOND      (-17)
2521    
2522         This  return  is  given  if pcre_dfa_exec() encounters a condition item         This return is given if pcre_dfa_exec()  encounters  a  condition  item
2523         that uses a back reference for the condition, or a test  for  recursion         that  uses  a back reference for the condition, or a test for recursion
2524         in a specific group. These are not supported.         in a specific group. These are not supported.
2525    
2526           PCRE_ERROR_DFA_UMLIMIT    (-18)           PCRE_ERROR_DFA_UMLIMIT    (-18)
2527    
2528         This  return  is given if pcre_dfa_exec() is called with an extra block         This return is given if pcre_dfa_exec() is called with an  extra  block
2529         that contains a setting of the match_limit field. This is not supported         that contains a setting of the match_limit field. This is not supported
2530         (it is meaningless).         (it is meaningless).
2531    
2532           PCRE_ERROR_DFA_WSSIZE     (-19)           PCRE_ERROR_DFA_WSSIZE     (-19)
2533    
2534         This  return  is  given  if  pcre_dfa_exec()  runs  out of space in the         This return is given if  pcre_dfa_exec()  runs  out  of  space  in  the
2535         workspace vector.         workspace vector.
2536    
2537           PCRE_ERROR_DFA_RECURSE    (-20)           PCRE_ERROR_DFA_RECURSE    (-20)
2538    
2539         When a recursive subpattern is processed, the matching  function  calls         When  a  recursive subpattern is processed, the matching function calls
2540         itself  recursively,  using  private vectors for ovector and workspace.         itself recursively, using private vectors for  ovector  and  workspace.
2541         This error is given if the output vector  is  not  large  enough.  This         This  error  is  given  if  the output vector is not large enough. This
2542         should be extremely rare, as a vector of size 1000 is used.         should be extremely rare, as a vector of size 1000 is used.
2543    
2544    
2545  SEE ALSO  SEE ALSO
2546    
2547         pcrebuild(3),  pcrecallout(3), pcrecpp(3)(3), pcrematching(3), pcrepar-         pcrebuild(3), pcrecallout(3), pcrecpp(3)(3), pcrematching(3),  pcrepar-
2548         tial(3), pcreposix(3), pcreprecompile(3), pcresample(3),  pcrestack(3).         tial(3),  pcreposix(3), pcreprecompile(3), pcresample(3), pcrestack(3).
2549    
2550    
2551  AUTHOR  AUTHOR
# Line 2524  AUTHOR Line 2557  AUTHOR
2557    
2558  REVISION  REVISION
2559    
2560         Last updated: 11 September 2007         Last updated: 27 November 2007
2561         Copyright (c) 1997-2007 University of Cambridge.         Copyright (c) 1997-2007 University of Cambridge.
2562  ------------------------------------------------------------------------------  ------------------------------------------------------------------------------
2563    
# Line 2910  NEWLINE CONVENTIONS Line 2943  NEWLINE CONVENTIONS
2943         The  newline  convention  does  not  affect what the \R escape sequence         The  newline  convention  does  not  affect what the \R escape sequence
2944         matches. By default, this is any Unicode  newline  sequence,  for  Perl         matches. By default, this is any Unicode  newline  sequence,  for  Perl
2945         compatibility.  However, this can be changed; see the description of \R         compatibility.  However, this can be changed; see the description of \R
2946         in the section entitled "Newline sequences" below.         in the section entitled "Newline sequences" below. A change of \R  set-
2947           ting can be combined with a change of newline convention.
2948    
2949    
2950  CHARACTERS AND METACHARACTERS  CHARACTERS AND METACHARACTERS
2951    
2952         A regular expression is a pattern that is  matched  against  a  subject         A  regular  expression  is  a pattern that is matched against a subject
2953         string  from  left  to right. Most characters stand for themselves in a         string from left to right. Most characters stand for  themselves  in  a
2954         pattern, and match the corresponding characters in the  subject.  As  a         pattern,  and  match  the corresponding characters in the subject. As a
2955         trivial example, the pattern         trivial example, the pattern
2956    
2957           The quick brown fox           The quick brown fox
2958    
2959         matches a portion of a subject string that is identical to itself. When         matches a portion of a subject string that is identical to itself. When
2960         caseless matching is specified (the PCRE_CASELESS option), letters  are         caseless  matching is specified (the PCRE_CASELESS option), letters are
2961         matched  independently  of case. In UTF-8 mode, PCRE always understands         matched independently of case. In UTF-8 mode, PCRE  always  understands
2962         the concept of case for characters whose values are less than  128,  so         the  concept  of case for characters whose values are less than 128, so
2963         caseless  matching  is always possible. For characters with higher val-         caseless matching is always possible. For characters with  higher  val-
2964         ues, the concept of case is supported if PCRE is compiled with  Unicode         ues,  the concept of case is supported if PCRE is compiled with Unicode
2965         property  support,  but  not  otherwise.   If  you want to use caseless         property support, but not otherwise.   If  you  want  to  use  caseless
2966         matching for characters 128 and above, you must  ensure  that  PCRE  is         matching  for  characters  128  and above, you must ensure that PCRE is
2967         compiled with Unicode property support as well as with UTF-8 support.         compiled with Unicode property support as well as with UTF-8 support.
2968    
2969         The  power  of  regular  expressions  comes from the ability to include         The power of regular expressions comes  from  the  ability  to  include
2970         alternatives and repetitions in the pattern. These are encoded  in  the         alternatives  and  repetitions in the pattern. These are encoded in the
2971         pattern by the use of metacharacters, which do not stand for themselves         pattern by the use of metacharacters, which do not stand for themselves
2972         but instead are interpreted in some special way.         but instead are interpreted in some special way.
2973    
2974         There are two different sets of metacharacters: those that  are  recog-         There  are  two different sets of metacharacters: those that are recog-
2975         nized  anywhere in the pattern except within square brackets, and those         nized anywhere in the pattern except within square brackets, and  those
2976         that are recognized within square brackets.  Outside  square  brackets,         that  are  recognized  within square brackets. Outside square brackets,
2977         the metacharacters are as follows:         the metacharacters are as follows:
2978    
2979           \      general escape character with several uses           \      general escape character with several uses
# Line 2958  CHARACTERS AND METACHARACTERS Line 2992  CHARACTERS AND METACHARACTERS
2992                  also "possessive quantifier"                  also "possessive quantifier"
2993           {      start min/max quantifier           {      start min/max quantifier
2994    
2995         Part  of  a  pattern  that is in square brackets is called a "character         Part of a pattern that is in square brackets  is  called  a  "character
2996         class". In a character class the only metacharacters are:         class". In a character class the only metacharacters are:
2997    
2998           \      general escape character           \      general escape character
# Line 2968  CHARACTERS AND METACHARACTERS Line 3002  CHARACTERS AND METACHARACTERS
3002                    syntax)                    syntax)
3003           ]      terminates the character class           ]      terminates the character class
3004    
3005         The following sections describe the use of each of the  metacharacters.         The  following sections describe the use of each of the metacharacters.
3006    
3007    
3008  BACKSLASH  BACKSLASH
3009    
3010         The backslash character has several uses. Firstly, if it is followed by         The backslash character has several uses. Firstly, if it is followed by
3011         a non-alphanumeric character, it takes away any  special  meaning  that         a  non-alphanumeric  character,  it takes away any special meaning that
3012         character  may  have.  This  use  of  backslash  as an escape character         character may have. This  use  of  backslash  as  an  escape  character
3013         applies both inside and outside character classes.         applies both inside and outside character classes.
3014    
3015         For example, if you want to match a * character, you write  \*  in  the         For  example,  if  you want to match a * character, you write \* in the
3016         pattern.   This  escaping  action  applies whether or not the following         pattern.  This escaping action applies whether  or  not  the  following
3017         character would otherwise be interpreted as a metacharacter, so  it  is         character  would  otherwise be interpreted as a metacharacter, so it is
3018         always  safe  to  precede  a non-alphanumeric with backslash to specify         always safe to precede a non-alphanumeric  with  backslash  to  specify
3019         that it stands for itself. In particular, if you want to match a  back-         that  it stands for itself. In particular, if you want to match a back-
3020         slash, you write \\.         slash, you write \\.
3021    
3022         If  a  pattern is compiled with the PCRE_EXTENDED option, whitespace in         If a pattern is compiled with the PCRE_EXTENDED option,  whitespace  in
3023         the pattern (other than in a character class) and characters between  a         the  pattern (other than in a character class) and characters between a
3024         # outside a character class and the next newline are ignored. An escap-         # outside a character class and the next newline are ignored. An escap-
3025         ing backslash can be used to include a whitespace  or  #  character  as         ing  backslash  can  be  used to include a whitespace or # character as
3026         part of the pattern.         part of the pattern.
3027    
3028         If  you  want  to remove the special meaning from a sequence of charac-         If you want to remove the special meaning from a  sequence  of  charac-
3029         ters, you can do so by putting them between \Q and \E. This is  differ-         ters,  you can do so by putting them between \Q and \E. This is differ-
3030         ent  from  Perl  in  that  $  and  @ are handled as literals in \Q...\E         ent from Perl in that $ and  @  are  handled  as  literals  in  \Q...\E
3031         sequences in PCRE, whereas in Perl, $ and @ cause  variable  interpola-         sequences  in  PCRE, whereas in Perl, $ and @ cause variable interpola-
3032         tion. Note the following examples:         tion. Note the following examples:
3033    
3034           Pattern            PCRE matches   Perl matches           Pattern            PCRE matches   Perl matches
# Line 3004  BACKSLASH Line 3038  BACKSLASH
3038           \Qabc\$xyz\E       abc\$xyz       abc\$xyz           \Qabc\$xyz\E       abc\$xyz       abc\$xyz
3039           \Qabc\E\$\Qxyz\E   abc$xyz        abc$xyz           \Qabc\E\$\Qxyz\E   abc$xyz        abc$xyz
3040    
3041         The  \Q...\E  sequence  is recognized both inside and outside character         The \Q...\E sequence is recognized both inside  and  outside  character
3042         classes.         classes.
3043    
3044     Non-printing characters     Non-printing characters
3045    
3046         A second use of backslash provides a way of encoding non-printing char-         A second use of backslash provides a way of encoding non-printing char-
3047         acters  in patterns in a visible manner. There is no restriction on the         acters in patterns in a visible manner. There is no restriction on  the
3048         appearance of non-printing characters, apart from the binary zero  that         appearance  of non-printing characters, apart from the binary zero that
3049         terminates  a  pattern,  but  when  a pattern is being prepared by text         terminates a pattern, but when a pattern  is  being  prepared  by  text
3050         editing, it is usually easier  to  use  one  of  the  following  escape         editing,  it  is  usually  easier  to  use  one of the following escape
3051         sequences than the binary character it represents:         sequences than the binary character it represents:
3052    
3053           \a        alarm, that is, the BEL character (hex 07)           \a        alarm, that is, the BEL character (hex 07)
# Line 3027  BACKSLASH Line 3061  BACKSLASH
3061           \xhh      character with hex code hh           \xhh      character with hex code hh
3062           \x{hhh..} character with hex code hhh..           \x{hhh..} character with hex code hhh..
3063    
3064         The  precise  effect of \cx is as follows: if x is a lower case letter,         The precise effect of \cx is as follows: if x is a lower  case  letter,
3065         it is converted to upper case. Then bit 6 of the character (hex 40)  is         it  is converted to upper case. Then bit 6 of the character (hex 40) is
3066         inverted.   Thus  \cz becomes hex 1A, but \c{ becomes hex 3B, while \c;         inverted.  Thus \cz becomes hex 1A, but \c{ becomes hex 3B,  while  \c;
3067         becomes hex 7B.         becomes hex 7B.
3068    
3069         After \x, from zero to two hexadecimal digits are read (letters can  be         After  \x, from zero to two hexadecimal digits are read (letters can be
3070         in  upper  or  lower case). Any number of hexadecimal digits may appear         in upper or lower case). Any number of hexadecimal  digits  may  appear
3071         between \x{ and }, but the value of the character  code  must  be  less         between  \x{  and  },  but the value of the character code must be less
3072         than 256 in non-UTF-8 mode, and less than 2**31 in UTF-8 mode. That is,         than 256 in non-UTF-8 mode, and less than 2**31 in UTF-8 mode. That is,
3073         the maximum value in hexadecimal is 7FFFFFFF. Note that this is  bigger         the  maximum value in hexadecimal is 7FFFFFFF. Note that this is bigger
3074         than the largest Unicode code point, which is 10FFFF.         than the largest Unicode code point, which is 10FFFF.
3075    
3076         If  characters  other than hexadecimal digits appear between \x{ and },         If characters other than hexadecimal digits appear between \x{  and  },
3077         or if there is no terminating }, this form of escape is not recognized.         or if there is no terminating }, this form of escape is not recognized.
3078         Instead,  the  initial  \x  will  be interpreted as a basic hexadecimal         Instead, the initial \x will be  interpreted  as  a  basic  hexadecimal
3079         escape, with no following digits, giving a  character  whose  value  is         escape,  with  no  following  digits, giving a character whose value is
3080         zero.         zero.
3081    
3082         Characters whose value is less than 256 can be defined by either of the         Characters whose value is less than 256 can be defined by either of the
3083         two syntaxes for \x. There is no difference in the way  they  are  han-         two  syntaxes  for  \x. There is no difference in the way they are han-
3084         dled. For example, \xdc is exactly the same as \x{dc}.         dled. For example, \xdc is exactly the same as \x{dc}.
3085    
3086         After  \0  up  to two further octal digits are read. If there are fewer         After \0 up to two further octal digits are read. If  there  are  fewer
3087         than two digits, just  those  that  are  present  are  used.  Thus  the         than  two  digits,  just  those  that  are  present  are used. Thus the
3088         sequence \0\x\07 specifies two binary zeros followed by a BEL character         sequence \0\x\07 specifies two binary zeros followed by a BEL character
3089         (code value 7). Make sure you supply two digits after the initial  zero         (code  value 7). Make sure you supply two digits after the initial zero
3090         if the pattern character that follows is itself an octal digit.         if the pattern character that follows is itself an octal digit.
3091    
3092         The handling of a backslash followed by a digit other than 0 is compli-         The handling of a backslash followed by a digit other than 0 is compli-
3093         cated.  Outside a character class, PCRE reads it and any following dig-         cated.  Outside a character class, PCRE reads it and any following dig-
3094         its  as  a  decimal  number. If the number is less than 10, or if there         its as a decimal number. If the number is less than  10,  or  if  there
3095         have been at least that many previous capturing left parentheses in the         have been at least that many previous capturing left parentheses in the
3096         expression,  the  entire  sequence  is  taken  as  a  back reference. A         expression, the entire  sequence  is  taken  as  a  back  reference.  A
3097         description of how this works is given later, following the  discussion         description  of how this works is given later, following the discussion
3098         of parenthesized subpatterns.         of parenthesized subpatterns.
3099    
3100         Inside  a  character  class, or if the decimal number is greater than 9         Inside a character class, or if the decimal number is  greater  than  9
3101         and there have not been that many capturing subpatterns, PCRE  re-reads         and  there have not been that many capturing subpatterns, PCRE re-reads
3102         up to three octal digits following the backslash, and uses them to gen-         up to three octal digits following the backslash, and uses them to gen-
3103         erate a data character. Any subsequent digits stand for themselves.  In         erate  a data character. Any subsequent digits stand for themselves. In
3104         non-UTF-8  mode,  the  value  of a character specified in octal must be         non-UTF-8 mode, the value of a character specified  in  octal  must  be
3105         less than \400. In UTF-8 mode, values up to  \777  are  permitted.  For         less  than  \400.  In  UTF-8 mode, values up to \777 are permitted. For
3106         example:         example:
3107    
3108           \040   is another way of writing a space           \040   is another way of writing a space
# Line 3086  BACKSLASH Line 3120  BACKSLASH
3120           \81    is either a back reference, or a binary zero           \81    is either a back reference, or a binary zero
3121                     followed by the two characters "8" and "1"                     followed by the two characters "8" and "1"
3122    
3123         Note  that  octal  values of 100 or greater must not be introduced by a         Note that octal values of 100 or greater must not be  introduced  by  a
3124         leading zero, because no more than three octal digits are ever read.         leading zero, because no more than three octal digits are ever read.
3125    
3126         All the sequences that define a single character value can be used both         All the sequences that define a single character value can be used both
3127         inside  and  outside character classes. In addition, inside a character         inside and outside character classes. In addition, inside  a  character
3128         class, the sequence \b is interpreted as the backspace  character  (hex         class,  the  sequence \b is interpreted as the backspace character (hex
3129         08),  and the sequences \R and \X are interpreted as the characters "R"         08), and the sequences \R and \X are interpreted as the characters  "R"
3130         and "X", respectively. Outside a character class, these sequences  have         and  "X", respectively. Outside a character class, these sequences have
3131         different meanings (see below).         different meanings (see below).
3132    
3133     Absolute and relative back references     Absolute and relative back references
3134    
3135         The  sequence  \g followed by an unsigned or a negative number, option-         The sequence \g followed by an unsigned or a negative  number,  option-
3136         ally enclosed in braces, is an absolute or relative back  reference.  A         ally  enclosed  in braces, is an absolute or relative back reference. A
3137         named back reference can be coded as \g{name}. Back references are dis-         named back reference can be coded as \g{name}. Back references are dis-
3138         cussed later, following the discussion of parenthesized subpatterns.         cussed later, following the discussion of parenthesized subpatterns.
3139    
# Line 3120  BACKSLASH Line 3154  BACKSLASH
3154           \W     any "non-word" character           \W     any "non-word" character
3155    
3156         Each pair of escape sequences partitions the complete set of characters         Each pair of escape sequences partitions the complete set of characters
3157         into two disjoint sets. Any given character matches one, and only  one,         into  two disjoint sets. Any given character matches one, and only one,
3158         of each pair.         of each pair.
3159    
3160         These character type sequences can appear both inside and outside char-         These character type sequences can appear both inside and outside char-
3161         acter classes. They each match one character of the  appropriate  type.         acter  classes.  They each match one character of the appropriate type.
3162         If  the current matching point is at the end of the subject string, all         If the current matching point is at the end of the subject string,  all
3163         of them fail, since there is no character to match.         of them fail, since there is no character to match.
3164    
3165         For compatibility with Perl, \s does not match the VT  character  (code         For  compatibility  with Perl, \s does not match the VT character (code
3166         11).   This makes it different from the the POSIX "space" class. The \s         11).  This makes it different from the the POSIX "space" class. The  \s
3167         characters are HT (9), LF (10), FF (12), CR (13), and  space  (32).  If         characters  are  HT  (9), LF (10), FF (12), CR (13), and space (32). If
3168         "use locale;" is included in a Perl script, \s may match the VT charac-         "use locale;" is included in a Perl script, \s may match the VT charac-
3169         ter. In PCRE, it never does.         ter. In PCRE, it never does.
3170    
3171         In UTF-8 mode, characters with values greater than 128 never match  \d,         In  UTF-8 mode, characters with values greater than 128 never match \d,
3172         \s, or \w, and always match \D, \S, and \W. This is true even when Uni-         \s, or \w, and always match \D, \S, and \W. This is true even when Uni-
3173         code character property support is available.  These  sequences  retain         code  character  property  support is available. These sequences retain
3174         their original meanings from before UTF-8 support was available, mainly         their original meanings from before UTF-8 support was available, mainly
3175         for efficiency reasons.         for efficiency reasons.
3176    
3177         The sequences \h, \H, \v, and \V are Perl 5.10 features. In contrast to         The sequences \h, \H, \v, and \V are Perl 5.10 features. In contrast to
3178         the  other  sequences, these do match certain high-valued codepoints in         the other sequences, these do match certain high-valued  codepoints  in
3179         UTF-8 mode.  The horizontal space characters are:         UTF-8 mode.  The horizontal space characters are:
3180    
3181           U+0009     Horizontal tab           U+0009     Horizontal tab
# Line 3175  BACKSLASH Line 3209  BACKSLASH
3209           U+2029     Paragraph separator           U+2029     Paragraph separator
3210    
3211         A "word" character is an underscore or any character less than 256 that         A "word" character is an underscore or any character less than 256 that
3212         is  a  letter  or  digit.  The definition of letters and digits is con-         is a letter or digit. The definition of  letters  and  digits  is  con-
3213         trolled by PCRE's low-valued character tables, and may vary if  locale-         trolled  by PCRE's low-valued character tables, and may vary if locale-
3214         specific  matching is taking place (see "Locale support" in the pcreapi         specific matching is taking place (see "Locale support" in the  pcreapi
3215         page). For example, in a French locale such  as  "fr_FR"  in  Unix-like         page).  For  example,  in  a French locale such as "fr_FR" in Unix-like
3216         systems,  or "french" in Windows, some character codes greater than 128         systems, or "french" in Windows, some character codes greater than  128
3217         are used for accented letters, and these are matched by \w. The use  of         are  used for accented letters, and these are matched by \w. The use of
3218         locales with Unicode is discouraged.         locales with Unicode is discouraged.
3219    
3220     Newline sequences     Newline sequences
3221    
3222         Outside  a  character class, by default, the escape sequence \R matches         Outside a character class, by default, the escape sequence  \R  matches
3223         any Unicode newline sequence. This is a Perl 5.10 feature. In non-UTF-8         any Unicode newline sequence. This is a Perl 5.10 feature. In non-UTF-8
3224         mode \R is equivalent to the following:         mode \R is equivalent to the following:
3225    
3226           (?>\r\n|\n|\x0b|\f|\r|\x85)           (?>\r\n|\n|\x0b|\f|\r|\x85)
3227    
3228         This  is  an  example  of an "atomic group", details of which are given         This is an example of an "atomic group", details  of  which  are  given
3229         below.  This particular group matches either the two-character sequence         below.  This particular group matches either the two-character sequence
3230         CR  followed  by  LF,  or  one  of  the single characters LF (linefeed,         CR followed by LF, or  one  of  the  single  characters  LF  (linefeed,
3231         U+000A), VT (vertical tab, U+000B), FF (formfeed, U+000C), CR (carriage         U+000A), VT (vertical tab, U+000B), FF (formfeed, U+000C), CR (carriage
3232         return, U+000D), or NEL (next line, U+0085). The two-character sequence         return, U+000D), or NEL (next line, U+0085). The two-character sequence
3233         is treated as a single unit that cannot be split.         is treated as a single unit that cannot be split.
3234    
3235         In UTF-8 mode, two additional characters whose codepoints  are  greater         In  UTF-8  mode, two additional characters whose codepoints are greater
3236         than 255 are added: LS (line separator, U+2028) and PS (paragraph sepa-         than 255 are added: LS (line separator, U+2028) and PS (paragraph sepa-
3237         rator, U+2029).  Unicode character property support is not  needed  for         rator,  U+2029).   Unicode character property support is not needed for
3238         these characters to be recognized.         these characters to be recognized.
3239    
3240         It is possible to restrict \R to match only CR, LF, or CRLF (instead of         It is possible to restrict \R to match only CR, LF, or CRLF (instead of
3241         the complete set  of  Unicode  line  endings)  by  setting  the  option         the  complete  set  of  Unicode  line  endings)  by  setting the option
3242         PCRE_BSR_ANYCRLF either at compile time or when the pattern is matched.         PCRE_BSR_ANYCRLF either at compile time or when the pattern is matched.
3243         This can be made the default when PCRE is built; if this is  the  case,         (BSR is an abbrevation for "backslash R".) This can be made the default
3244         the  other  behaviour can be requested via the PCRE_BSR_UNICODE option.         when PCRE is built; if this is the case, the  other  behaviour  can  be
3245         It is also possible to specify these settings  by  starting  a  pattern         requested  via  the  PCRE_BSR_UNICODE  option.   It is also possible to
3246         string with one of the following sequences:         specify these settings by starting a pattern string  with  one  of  the
3247           following sequences:
3248    
3249           (*BSR_ANYCRLF)   CR, LF, or CRLF only           (*BSR_ANYCRLF)   CR, LF, or CRLF only
3250           (*BSR_UNICODE)   any Unicode newline sequence           (*BSR_UNICODE)   any Unicode newline sequence
# Line 3218  BACKSLASH Line 3253  BACKSLASH
3253         they can be overridden by options given to pcre_exec(). Note that these         they can be overridden by options given to pcre_exec(). Note that these
3254         special settings, which are not Perl-compatible, are recognized only at         special settings, which are not Perl-compatible, are recognized only at
3255         the very start of a pattern, and that they must be in  upper  case.  If         the very start of a pattern, and that they must be in  upper  case.  If
3256         more than one of them is present, the last one is used.         more  than  one  of  them is present, the last one is used. They can be
3257           combined with a change of newline convention, for  example,  a  pattern
3258           can start with:
3259    
3260             (*ANY)(*BSR_ANYCRLF)
3261    
3262         Inside a character class, \R matches the letter "R".         Inside a character class, \R matches the letter "R".
3263    
# Line 3675  VERTICAL BAR Line 3714  VERTICAL BAR
3714  INTERNAL OPTION SETTING  INTERNAL OPTION SETTING
3715    
3716         The  settings  of  the  PCRE_CASELESS, PCRE_MULTILINE, PCRE_DOTALL, and         The  settings  of  the  PCRE_CASELESS, PCRE_MULTILINE, PCRE_DOTALL, and
3717         PCRE_EXTENDED options can be changed  from  within  the  pattern  by  a         PCRE_EXTENDED options (which are Perl-compatible) can be  changed  from
3718         sequence  of  Perl  option  letters  enclosed between "(?" and ")". The         within  the  pattern  by  a  sequence  of  Perl option letters enclosed
3719         option letters are         between "(?" and ")".  The option letters are
3720    
3721           i  for PCRE_CASELESS           i  for PCRE_CASELESS
3722           m  for PCRE_MULTILINE           m  for PCRE_MULTILINE
# Line 3691  INTERNAL OPTION SETTING Line 3730  INTERNAL OPTION SETTING
3730         is also permitted. If a  letter  appears  both  before  and  after  the         is also permitted. If a  letter  appears  both  before  and  after  the
3731         hyphen, the option is unset.         hyphen, the option is unset.
3732    
3733           The  PCRE-specific options PCRE_DUPNAMES, PCRE_UNGREEDY, and PCRE_EXTRA
3734           can be changed in the same way as the Perl-compatible options by  using
3735           the characters J, U and X respectively.
3736    
3737         When  an option change occurs at top level (that is, not inside subpat-         When  an option change occurs at top level (that is, not inside subpat-
3738         tern parentheses), the change applies to the remainder of  the  pattern         tern parentheses), the change applies to the remainder of  the  pattern
3739         that follows.  If the change is placed right at the start of a pattern,         that follows.  If the change is placed right at the start of a pattern,
# Line 3716  INTERNAL OPTION SETTING Line 3759  INTERNAL OPTION SETTING
3759         the  effects  of option settings happen at compile time. There would be         the  effects  of option settings happen at compile time. There would be
3760         some very weird behaviour otherwise.         some very weird behaviour otherwise.
3761    
3762         The PCRE-specific options PCRE_DUPNAMES, PCRE_UNGREEDY, and  PCRE_EXTRA         Note: There are other PCRE-specific options that  can  be  set  by  the
3763         can  be changed in the same way as the Perl-compatible options by using         application  when  the  compile  or match functions are called. In some
3764         the characters J, U and X respectively.         cases the pattern can contain special  leading  sequences  to  override
3765           what  the  application  has set or what has been defaulted. Details are
3766           given in the section entitled "Newline sequences" above.
3767    
3768    
3769  SUBPATTERNS  SUBPATTERNS
# Line 4718  CALLOUTS Line 4763  CALLOUTS
4763         is given in the pcrecallout documentation.         is given in the pcrecallout documentation.
4764    
4765    
4766  BACTRACKING CONTROL  BACKTRACKING CONTROL
4767    
4768         Perl 5.10 introduced a number of "Special Backtracking Control  Verbs",         Perl 5.10 introduced a number of "Special Backtracking Control  Verbs",
4769         which are described in the Perl documentation as "experimental and sub-         which are described in the Perl documentation as "experimental and sub-
# Line 4849  AUTHOR Line 4894  AUTHOR
4894    
4895  REVISION  REVISION
4896    
4897         Last updated: 11 September 2007         Last updated: 17 September 2007
4898         Copyright (c) 1997-2007 University of Cambridge.         Copyright (c) 1997-2007 University of Cambridge.
4899  ------------------------------------------------------------------------------  ------------------------------------------------------------------------------
4900    
# Line 4978  CHARACTER CLASSES Line 5023  CHARACTER CLASSES
5023           [^...]      negative character class           [^...]      negative character class
5024           [x-y]       range (can be used for hex characters)           [x-y]       range (can be used for hex characters)
5025           [[:xxx:]]   positive POSIX named set           [[:xxx:]]   positive POSIX named set
5026           [[^:xxx:]]  negative POSIX named set           [[:^xxx:]]  negative POSIX named set
5027    
5028           alnum       alphanumeric           alnum       alphanumeric
5029           alpha       alphabetic           alpha       alphabetic
# Line 5148  BACKTRACKING CONTROL Line 5193  BACKTRACKING CONTROL
5193    
5194  NEWLINE CONVENTIONS  NEWLINE CONVENTIONS
5195    
5196         These are recognized only at the very start of a pattern.         These  are  recognized only at the very start of the pattern or after a
5197           (*BSR_...) option.
5198    
5199           (*CR)           (*CR)
5200           (*LF)           (*LF)
# Line 5159  NEWLINE CONVENTIONS Line 5205  NEWLINE CONVENTIONS
5205    
5206  WHAT \R MATCHES  WHAT \R MATCHES
5207    
5208         These are recognized only at the very start of a pattern.         These are recognized only at the very start of the pattern or  after  a
5209           (*...) option that sets the newline convention.
5210    
5211           (*BSR_ANYCRLF)           (*BSR_ANYCRLF)
5212           (*BSR_UNICODE)           (*BSR_UNICODE)
# Line 5185  AUTHOR Line 5232  AUTHOR
5232    
5233  REVISION  REVISION
5234    
5235         Last updated: 11 September 2007         Last updated: 14 November 2007
5236         Copyright (c) 1997-2007 University of Cambridge.         Copyright (c) 1997-2007 University of Cambridge.
5237  ------------------------------------------------------------------------------  ------------------------------------------------------------------------------
5238    
# Line 5989  MATCHING INTERFACE Line 6036  MATCHING INTERFACE
6036    
6037           c. The "i"th argument has a suitable type for holding the           c. The "i"th argument has a suitable type for holding the
6038              string captured as the "i"th sub-pattern. If you pass in              string captured as the "i"th sub-pattern. If you pass in
6039              NULL for the "i"th argument, or pass fewer arguments than              void * NULL for the "i"th argument, or a non-void * NULL
6040                of the correct type, or pass fewer arguments than the
6041              number of sub-patterns, "i"th captured sub-pattern is              number of sub-patterns, "i"th captured sub-pattern is
6042              ignored.              ignored.
6043    
# Line 6237  AUTHOR Line 6285  AUTHOR
6285    
6286  REVISION  REVISION
6287    
6288         Last updated: 06 March 2007         Last updated: 12 November 2007
6289  ------------------------------------------------------------------------------  ------------------------------------------------------------------------------
6290    
6291    

Legend:
Removed from v.231  
changed lines
  Added in v.289

  ViewVC Help
Powered by ViewVC 1.1.5