/[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 589 by ph10, Sat Jan 15 11:31:39 2011 UTC revision 654 by ph10, Tue Aug 2 11:00:40 2011 UTC
# Line 29  INTRODUCTION Line 29  INTRODUCTION
29         5.12, including support for UTF-8 encoded strings and  Unicode  general         5.12, including support for UTF-8 encoded strings and  Unicode  general
30         category  properties.  However,  UTF-8  and  Unicode  support has to be         category  properties.  However,  UTF-8  and  Unicode  support has to be
31         explicitly enabled; it is not the default. The  Unicode  tables  corre-         explicitly enabled; it is not the default. The  Unicode  tables  corre-
32         spond to Unicode release 5.2.0.         spond to Unicode release 6.0.0.
33    
34         In  addition to the Perl-compatible matching function, PCRE contains an         In  addition to the Perl-compatible matching function, PCRE contains an
35         alternative function that matches the same compiled patterns in a  dif-         alternative function that matches the same compiled patterns in a  dif-
# Line 181  UTF-8 AND UNICODE PROPERTY SUPPORT Line 181  UTF-8 AND UNICODE PROPERTY SUPPORT
181         points in the UTF-8 encoding. (In  other  words,  the  whole  surrogate         points in the UTF-8 encoding. (In  other  words,  the  whole  surrogate
182         thing is a fudge for UTF-16 which unfortunately messes up UTF-8.)         thing is a fudge for UTF-16 which unfortunately messes up UTF-8.)
183    
184         If  an  invalid  UTF-8  string  is  passed  to  PCRE,  an  error return         If an invalid UTF-8 string is passed to PCRE, an error return is given.
185         (PCRE_ERROR_BADUTF8) is given. In some situations, you may already know         At compile time, the only additional information is the offset  to  the
186         that your strings are valid, and therefore want to skip these checks in         first byte of the failing character. The runtime functions (pcre_exec()
187         order to improve performance. If you set the PCRE_NO_UTF8_CHECK flag at         and pcre_dfa_exec()), pass back this information  as  well  as  a  more
188         compile  time  or at run time, PCRE assumes that the pattern or subject         detailed  reason  code if the caller has provided memory in which to do
189         it is given (respectively) contains only valid  UTF-8  codes.  In  this         this.
190         case, it does not diagnose an invalid UTF-8 string.  
191           In some situations, you may already know that your strings  are  valid,
192           and  therefore  want  to  skip these checks in order to improve perfor-
193           mance. If you set the PCRE_NO_UTF8_CHECK flag at compile time or at run
194           time,  PCRE  assumes  that  the pattern or subject it is given (respec-
195           tively) contains only valid UTF-8 codes. In  this  case,  it  does  not
196           diagnose an invalid UTF-8 string.
197    
198         If  you  pass  an  invalid UTF-8 string when PCRE_NO_UTF8_CHECK is set,         If  you  pass  an  invalid UTF-8 string when PCRE_NO_UTF8_CHECK is set,
199         what happens depends on why the string is invalid. If the  string  con-         what happens depends on why the string is invalid. If the  string  con-
# Line 266  AUTHOR Line 272  AUTHOR
272    
273  REVISION  REVISION
274    
275         Last updated: 13 November 2010         Last updated: 07 May 2011
276         Copyright (c) 1997-2010 University of Cambridge.         Copyright (c) 1997-2011 University of Cambridge.
277  ------------------------------------------------------------------------------  ------------------------------------------------------------------------------
278    
279    
# Line 307  PCRE BUILD-TIME OPTIONS Line 313  PCRE BUILD-TIME OPTIONS
313         is not described.         is not described.
314    
315    
316    BUILDING SHARED AND STATIC LIBRARIES
317    
318           The  PCRE building process uses libtool to build both shared and static
319           Unix libraries by default. You can suppress one of these by adding  one
320           of
321    
322             --disable-shared
323             --disable-static
324    
325           to the configure command, as required.
326    
327    
328  C++ SUPPORT  C++ SUPPORT
329    
330         By default, the configure script will search for a C++ compiler and C++         By default, the configure script will search for a C++ compiler and C++
# Line 400  WHAT \R MATCHES Line 418  WHAT \R MATCHES
418         functions are called.         functions are called.
419    
420    
 BUILDING SHARED AND STATIC LIBRARIES  
   
        The  PCRE building process uses libtool to build both shared and static  
        Unix libraries by default. You can suppress one of these by adding  one  
        of  
   
          --disable-shared  
          --disable-static  
   
        to the configure command, as required.  
   
   
421  POSIX MALLOC USAGE  POSIX MALLOC USAGE
422    
423         When PCRE is called through the POSIX interface (see the pcreposix doc-         When PCRE is called through the POSIX interface (see the pcreposix doc-
# Line 552  PCREGREP OPTIONS FOR COMPRESSED FILE SUP Line 558  PCREGREP OPTIONS FOR COMPRESSED FILE SUP
558         if they are not.         if they are not.
559    
560    
561    PCREGREP BUFFER SIZE
562    
563           pcregrep  uses  an internal buffer to hold a "window" on the file it is
564           scanning, in order to be able to output "before" and "after" lines when
565           it  finds  a match. The size of the buffer is controlled by a parameter
566           whose default value is 20K. The buffer itself is three times this size,
567           but because of the way it is used for holding "before" lines, the long-
568           est line that is guaranteed to be processable is  the  parameter  size.
569           You can change the default parameter value by adding, for example,
570    
571             --with-pcregrep-bufsize=50K
572    
573           to the configure command. The caller of pcregrep can, however, override
574           this value by specifying a run-time option.
575    
576    
577  PCRETEST OPTION FOR LIBREADLINE SUPPORT  PCRETEST OPTION FOR LIBREADLINE SUPPORT
578    
579         If you add         If you add
580    
581           --enable-pcretest-libreadline           --enable-pcretest-libreadline
582    
583         to  the  configure  command,  pcretest  is  linked with the libreadline         to the configure command,  pcretest  is  linked  with  the  libreadline
584         library, and when its input is from a terminal, it reads it  using  the         library,  and  when its input is from a terminal, it reads it using the
585         readline() function. This provides line-editing and history facilities.         readline() function. This provides line-editing and history facilities.
586         Note that libreadline is GPL-licensed, so if you distribute a binary of         Note that libreadline is GPL-licensed, so if you distribute a binary of
587         pcretest linked in this way, there may be licensing issues.         pcretest linked in this way, there may be licensing issues.
588    
589         Setting  this  option  causes  the -lreadline option to be added to the         Setting this option causes the -lreadline option to  be  added  to  the
590         pcretest build. In many operating environments with  a  sytem-installed         pcretest  build.  In many operating environments with a sytem-installed
591         libreadline this is sufficient. However, in some environments (e.g.  if         libreadline this is sufficient. However, in some environments (e.g.  if
592         an unmodified distribution version of readline is in use),  some  extra         an  unmodified  distribution version of readline is in use), some extra
593         configuration  may  be necessary. The INSTALL file for libreadline says         configuration may be necessary. The INSTALL file for  libreadline  says
594         this:         this:
595    
596           "Readline uses the termcap functions, but does not link with the           "Readline uses the termcap functions, but does not link with the
597           termcap or curses library itself, allowing applications which link           termcap or curses library itself, allowing applications which link
598           with readline the to choose an appropriate library."           with readline the to choose an appropriate library."
599    
600         If your environment has not been set up so that an appropriate  library         If  your environment has not been set up so that an appropriate library
601         is automatically included, you may need to add something like         is automatically included, you may need to add something like
602    
603           LIBS="-ncurses"           LIBS="-ncurses"
# Line 597  AUTHOR Line 619  AUTHOR
619    
620  REVISION  REVISION
621    
622         Last updated: 29 September 2009         Last updated: 02 August 2011
623         Copyright (c) 1997-2009 University of Cambridge.         Copyright (c) 1997-2011 University of Cambridge.
624  ------------------------------------------------------------------------------  ------------------------------------------------------------------------------
625    
626    
# Line 1173  COMPILING A PATTERN Line 1195  COMPILING A PATTERN
1195         if compilation of a pattern fails,  pcre_compile()  returns  NULL,  and         if compilation of a pattern fails,  pcre_compile()  returns  NULL,  and
1196         sets the variable pointed to by errptr to point to a textual error mes-         sets the variable pointed to by errptr to point to a textual error mes-
1197         sage. This is a static string that is part of the library. You must not         sage. This is a static string that is part of the library. You must not
1198         try  to  free  it. The offset from the start of the pattern to the byte         try  to  free it. Normally, the offset from the start of the pattern to
1199         that was being processed when the error was discovered is placed in the         the byte that was being processed when  the  error  was  discovered  is
1200         variable  pointed to by erroffset, which must not be NULL. If it is, an         placed  in the variable pointed to by erroffset, which must not be NULL
1201         immediate error is given. Some errors are not detected until checks are         (if it is, an immediate error is given). However, for an invalid  UTF-8
1202         carried  out  when the whole pattern has been scanned; in this case the         string,  the offset is that of the first byte of the failing character.
1203         offset is set to the end of the pattern.         Also, some errors are not detected until checks are  carried  out  when
1204           the  whole  pattern  has been scanned; in these cases the offset passed
1205           back is the length of the pattern.
1206    
1207         Note that the offset is in bytes, not characters, even in  UTF-8  mode.         Note that the offset is in bytes, not characters, even in  UTF-8  mode.
1208         It  may  point  into the middle of a UTF-8 character (for example, when         It may sometimes point into the middle of a UTF-8 character.
        PCRE_ERROR_BADUTF8 is returned for an invalid UTF-8 string).  
1209    
1210         If pcre_compile2() is used instead of pcre_compile(),  and  the  error-         If  pcre_compile2()  is  used instead of pcre_compile(), and the error-
1211         codeptr  argument is not NULL, a non-zero error code number is returned         codeptr argument is not NULL, a non-zero error code number is  returned
1212         via this argument in the event of an error. This is in addition to  the         via  this argument in the event of an error. This is in addition to the
1213         textual error message. Error codes and messages are listed below.         textual error message. Error codes and messages are listed below.
1214    
1215         If  the  final  argument, tableptr, is NULL, PCRE uses a default set of         If the final argument, tableptr, is NULL, PCRE uses a  default  set  of
1216         character tables that are  built  when  PCRE  is  compiled,  using  the         character  tables  that  are  built  when  PCRE  is compiled, using the
1217         default  C  locale.  Otherwise, tableptr must be an address that is the         default C locale. Otherwise, tableptr must be an address  that  is  the
1218         result of a call to pcre_maketables(). This value is  stored  with  the         result  of  a  call to pcre_maketables(). This value is stored with the
1219         compiled  pattern,  and used again by pcre_exec(), unless another table         compiled pattern, and used again by pcre_exec(), unless  another  table
1220         pointer is passed to it. For more discussion, see the section on locale         pointer is passed to it. For more discussion, see the section on locale
1221         support below.         support below.
1222    
1223         This  code  fragment  shows a typical straightforward call to pcre_com-         This code fragment shows a typical straightforward  call  to  pcre_com-
1224         pile():         pile():
1225    
1226           pcre *re;           pcre *re;
# Line 1210  COMPILING A PATTERN Line 1233  COMPILING A PATTERN
1233             &erroffset,       /* for error offset */             &erroffset,       /* for error offset */
1234             NULL);            /* use default character tables */             NULL);            /* use default character tables */
1235    
1236         The following names for option bits are defined in  the  pcre.h  header         The  following  names  for option bits are defined in the pcre.h header
1237         file:         file:
1238    
1239           PCRE_ANCHORED           PCRE_ANCHORED
1240    
1241         If this bit is set, the pattern is forced to be "anchored", that is, it         If this bit is set, the pattern is forced to be "anchored", that is, it
1242         is constrained to match only at the first matching point in the  string         is  constrained to match only at the first matching point in the string
1243         that  is being searched (the "subject string"). This effect can also be         that is being searched (the "subject string"). This effect can also  be
1244         achieved by appropriate constructs in the pattern itself, which is  the         achieved  by appropriate constructs in the pattern itself, which is the
1245         only way to do it in Perl.         only way to do it in Perl.
1246    
1247           PCRE_AUTO_CALLOUT           PCRE_AUTO_CALLOUT
1248    
1249         If this bit is set, pcre_compile() automatically inserts callout items,         If this bit is set, pcre_compile() automatically inserts callout items,
1250         all with number 255, before each pattern item. For  discussion  of  the         all  with  number  255, before each pattern item. For discussion of the
1251         callout facility, see the pcrecallout documentation.         callout facility, see the pcrecallout documentation.
1252    
1253           PCRE_BSR_ANYCRLF           PCRE_BSR_ANYCRLF
1254           PCRE_BSR_UNICODE           PCRE_BSR_UNICODE
1255    
1256         These options (which are mutually exclusive) control what the \R escape         These options (which are mutually exclusive) control what the \R escape
1257         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,
1258         or to match any Unicode newline sequence. The default is specified when         or to match any Unicode newline sequence. The default is specified when
1259         PCRE is built. It can be overridden from within the pattern, or by set-         PCRE is built. It can be overridden from within the pattern, or by set-
1260         ting an option when a compiled pattern is matched.         ting an option when a compiled pattern is matched.
1261    
1262           PCRE_CASELESS           PCRE_CASELESS
1263    
1264         If  this  bit is set, letters in the pattern match both upper and lower         If this bit is set, letters in the pattern match both upper  and  lower
1265         case letters. It is equivalent to Perl's  /i  option,  and  it  can  be         case  letters.  It  is  equivalent  to  Perl's /i option, and it can be
1266         changed  within a pattern by a (?i) option setting. In UTF-8 mode, PCRE         changed within a pattern by a (?i) option setting. In UTF-8 mode,  PCRE
1267         always understands the concept of case for characters whose values  are         always  understands the concept of case for characters whose values are
1268         less  than 128, so caseless matching is always possible. For characters         less than 128, so caseless matching is always possible. For  characters
1269         with higher values, the concept of case is supported if  PCRE  is  com-         with  higher  values,  the concept of case is supported if PCRE is com-
1270         piled  with Unicode property support, but not otherwise. If you want to         piled with Unicode property support, but not otherwise. If you want  to
1271         use caseless matching for characters 128 and  above,  you  must  ensure         use  caseless  matching  for  characters 128 and above, you must ensure
1272         that  PCRE  is  compiled  with Unicode property support as well as with         that PCRE is compiled with Unicode property support  as  well  as  with
1273         UTF-8 support.         UTF-8 support.
1274    
1275           PCRE_DOLLAR_ENDONLY           PCRE_DOLLAR_ENDONLY
1276    
1277         If this bit is set, a dollar metacharacter in the pattern matches  only         If  this bit is set, a dollar metacharacter in the pattern matches only
1278         at  the  end  of the subject string. Without this option, a dollar also         at the end of the subject string. Without this option,  a  dollar  also
1279         matches immediately before a newline at the end of the string (but  not         matches  immediately before a newline at the end of the string (but not
1280         before  any  other newlines). The PCRE_DOLLAR_ENDONLY option is ignored         before any other newlines). The PCRE_DOLLAR_ENDONLY option  is  ignored
1281         if PCRE_MULTILINE is set.  There is no equivalent  to  this  option  in         if  PCRE_MULTILINE  is  set.   There is no equivalent to this option in
1282         Perl, and no way to set it within a pattern.         Perl, and no way to set it within a pattern.
1283    
1284           PCRE_DOTALL           PCRE_DOTALL
1285    
1286         If  this bit is set, a dot metacharacter in the pattern matches a char-         If this bit is set, a dot metacharacter in the pattern matches a  char-
1287         acter of any value, including one that indicates a newline. However, it         acter of any value, including one that indicates a newline. However, it
1288         only  ever  matches  one character, even if newlines are coded as CRLF.         only ever matches one character, even if newlines are  coded  as  CRLF.
1289         Without this option, a dot does not match when the current position  is         Without  this option, a dot does not match when the current position is
1290         at a newline. This option is equivalent to Perl's /s option, and it can         at a newline. This option is equivalent to Perl's /s option, and it can
1291         be changed within a pattern by a (?s) option setting. A negative  class         be  changed within a pattern by a (?s) option setting. A negative class
1292         such as [^a] always matches newline characters, independent of the set-         such as [^a] always matches newline characters, independent of the set-
1293         ting of this option.         ting of this option.
1294    
1295           PCRE_DUPNAMES           PCRE_DUPNAMES
1296    
1297         If this bit is set, names used to identify capturing  subpatterns  need         If  this  bit is set, names used to identify capturing subpatterns need
1298         not be unique. This can be helpful for certain types of pattern when it         not be unique. This can be helpful for certain types of pattern when it
1299         is known that only one instance of the named  subpattern  can  ever  be         is  known  that  only  one instance of the named subpattern can ever be
1300         matched.  There  are  more details of named subpatterns below; see also         matched. There are more details of named subpatterns  below;  see  also
1301         the pcrepattern documentation.         the pcrepattern documentation.
1302    
1303           PCRE_EXTENDED           PCRE_EXTENDED
1304    
1305         If this bit is set, whitespace  data  characters  in  the  pattern  are         If  this  bit  is  set,  whitespace  data characters in the pattern are
1306         totally ignored except when escaped or inside a character class. White-         totally ignored except when escaped or inside a character class. White-
1307         space does not include the VT character (code 11). In addition, charac-         space does not include the VT character (code 11). In addition, charac-
1308         ters between an unescaped # outside a character class and the next new-         ters between an unescaped # outside a character class and the next new-
1309         line, inclusive, are also ignored. This  is  equivalent  to  Perl's  /x         line,  inclusive,  are  also  ignored.  This is equivalent to Perl's /x
1310         option,  and  it  can be changed within a pattern by a (?x) option set-         option, and it can be changed within a pattern by a  (?x)  option  set-
1311         ting.         ting.
1312    
1313         Which characters are interpreted  as  newlines  is  controlled  by  the         Which  characters  are  interpreted  as  newlines  is controlled by the
1314         options  passed to pcre_compile() or by a special sequence at the start         options passed to pcre_compile() or by a special sequence at the  start
1315         of the pattern, as described in the section entitled  "Newline  conven-         of  the  pattern, as described in the section entitled "Newline conven-
1316         tions" in the pcrepattern documentation. Note that the end of this type         tions" in the pcrepattern documentation. Note that the end of this type
1317         of comment is  a  literal  newline  sequence  in  the  pattern;  escape         of  comment  is  a  literal  newline  sequence  in  the pattern; escape
1318         sequences that happen to represent a newline do not count.         sequences that happen to represent a newline do not count.
1319    
1320         This  option  makes  it possible to include comments inside complicated         This option makes it possible to include  comments  inside  complicated
1321         patterns.  Note, however, that this applies only  to  data  characters.         patterns.   Note,  however,  that this applies only to data characters.
1322         Whitespace   characters  may  never  appear  within  special  character         Whitespace  characters  may  never  appear  within  special   character
1323         sequences in a pattern, for example within the sequence (?( that intro-         sequences in a pattern, for example within the sequence (?( that intro-
1324         duces a conditional subpattern.         duces a conditional subpattern.
1325    
1326           PCRE_EXTRA           PCRE_EXTRA
1327    
1328         This  option  was invented in order to turn on additional functionality         This option was invented in order to turn on  additional  functionality
1329         of PCRE that is incompatible with Perl, but it  is  currently  of  very         of  PCRE  that  is  incompatible with Perl, but it is currently of very
1330         little  use. When set, any backslash in a pattern that is followed by a         little use. When set, any backslash in a pattern that is followed by  a
1331         letter that has no special meaning  causes  an  error,  thus  reserving         letter  that  has  no  special  meaning causes an error, thus reserving
1332         these  combinations  for  future  expansion.  By default, as in Perl, a         these combinations for future expansion. By  default,  as  in  Perl,  a
1333         backslash followed by a letter with no special meaning is treated as  a         backslash  followed by a letter with no special meaning is treated as a
1334         literal. (Perl can, however, be persuaded to give an error for this, by         literal. (Perl can, however, be persuaded to give an error for this, by
1335         running it with the -w option.) There are at present no other  features         running  it with the -w option.) There are at present no other features
1336         controlled  by this option. It can also be set by a (?X) option setting         controlled by this option. It can also be set by a (?X) option  setting
1337         within a pattern.         within a pattern.
1338    
1339           PCRE_FIRSTLINE           PCRE_FIRSTLINE
1340    
1341         If this option is set, an  unanchored  pattern  is  required  to  match         If  this  option  is  set,  an  unanchored pattern is required to match
1342         before  or  at  the  first  newline  in  the subject string, though the         before or at the first  newline  in  the  subject  string,  though  the
1343         matched text may continue over the newline.         matched text may continue over the newline.
1344    
1345           PCRE_JAVASCRIPT_COMPAT           PCRE_JAVASCRIPT_COMPAT
1346    
1347         If this option is set, PCRE's behaviour is changed in some ways so that         If this option is set, PCRE's behaviour is changed in some ways so that
1348         it  is  compatible with JavaScript rather than Perl. The changes are as         it is compatible with JavaScript rather than Perl. The changes  are  as
1349         follows:         follows:
1350    
1351         (1) A lone closing square bracket in a pattern  causes  a  compile-time         (1)  A  lone  closing square bracket in a pattern causes a compile-time
1352         error,  because this is illegal in JavaScript (by default it is treated         error, because this is illegal in JavaScript (by default it is  treated
1353         as a data character). Thus, the pattern AB]CD becomes illegal when this         as a data character). Thus, the pattern AB]CD becomes illegal when this
1354         option is set.         option is set.
1355    
1356         (2)  At run time, a back reference to an unset subpattern group matches         (2) At run time, a back reference to an unset subpattern group  matches
1357         an empty string (by default this causes the current  matching  alterna-         an  empty  string (by default this causes the current matching alterna-
1358         tive  to  fail). A pattern such as (\1)(a) succeeds when this option is         tive to fail). A pattern such as (\1)(a) succeeds when this  option  is
1359         set (assuming it can find an "a" in the subject), whereas it  fails  by         set  (assuming  it can find an "a" in the subject), whereas it fails by
1360         default, for Perl compatibility.         default, for Perl compatibility.
1361    
1362           PCRE_MULTILINE           PCRE_MULTILINE
1363    
1364         By  default,  PCRE  treats the subject string as consisting of a single         By default, PCRE treats the subject string as consisting  of  a  single
1365         line of characters (even if it actually contains newlines). The  "start         line  of characters (even if it actually contains newlines). The "start
1366         of  line"  metacharacter  (^)  matches only at the start of the string,         of line" metacharacter (^) matches only at the  start  of  the  string,
1367         while the "end of line" metacharacter ($) matches only at  the  end  of         while  the  "end  of line" metacharacter ($) matches only at the end of
1368         the string, or before a terminating newline (unless PCRE_DOLLAR_ENDONLY         the string, or before a terminating newline (unless PCRE_DOLLAR_ENDONLY
1369         is set). This is the same as Perl.         is set). This is the same as Perl.
1370    
1371         When PCRE_MULTILINE it is set, the "start of line" and  "end  of  line"         When  PCRE_MULTILINE  it  is set, the "start of line" and "end of line"
1372         constructs  match  immediately following or immediately before internal         constructs match immediately following or immediately  before  internal
1373         newlines in the subject string, respectively, as well as  at  the  very         newlines  in  the  subject string, respectively, as well as at the very
1374         start  and  end.  This is equivalent to Perl's /m option, and it can be         start and end. This is equivalent to Perl's /m option, and  it  can  be
1375         changed within a pattern by a (?m) option setting. If there are no new-         changed within a pattern by a (?m) option setting. If there are no new-
1376         lines  in  a  subject string, or no occurrences of ^ or $ in a pattern,         lines in a subject string, or no occurrences of ^ or $  in  a  pattern,
1377         setting PCRE_MULTILINE has no effect.         setting PCRE_MULTILINE has no effect.
1378    
1379           PCRE_NEWLINE_CR           PCRE_NEWLINE_CR
# Line 1359  COMPILING A PATTERN Line 1382  COMPILING A PATTERN
1382           PCRE_NEWLINE_ANYCRLF           PCRE_NEWLINE_ANYCRLF
1383           PCRE_NEWLINE_ANY           PCRE_NEWLINE_ANY
1384    
1385         These options override the default newline definition that  was  chosen         These  options  override the default newline definition that was chosen
1386         when  PCRE  was built. Setting the first or the second specifies that a         when PCRE was built. Setting the first or the second specifies  that  a
1387         newline is indicated by a single character (CR  or  LF,  respectively).         newline  is  indicated  by a single character (CR or LF, respectively).
1388         Setting  PCRE_NEWLINE_CRLF specifies that a newline is indicated by the         Setting PCRE_NEWLINE_CRLF specifies that a newline is indicated by  the
1389         two-character CRLF  sequence.  Setting  PCRE_NEWLINE_ANYCRLF  specifies         two-character  CRLF  sequence.  Setting  PCRE_NEWLINE_ANYCRLF specifies
1390         that any of the three preceding sequences should be recognized. Setting         that any of the three preceding sequences should be recognized. Setting
1391         PCRE_NEWLINE_ANY specifies that any Unicode newline sequence should  be         PCRE_NEWLINE_ANY  specifies that any Unicode newline sequence should be
1392         recognized. The Unicode newline sequences are the three just mentioned,         recognized. The Unicode newline sequences are the three just mentioned,
1393         plus the single characters VT (vertical  tab,  U+000B),  FF  (formfeed,         plus  the  single  characters  VT (vertical tab, U+000B), FF (formfeed,
1394         U+000C),  NEL  (next line, U+0085), LS (line separator, U+2028), and PS         U+000C), NEL (next line, U+0085), LS (line separator, U+2028),  and  PS
1395         (paragraph separator, U+2029). The last  two  are  recognized  only  in         (paragraph  separator,  U+2029).  The  last  two are recognized only in
1396         UTF-8 mode.         UTF-8 mode.
1397    
1398         The  newline  setting  in  the  options  word  uses three bits that are         The newline setting in the  options  word  uses  three  bits  that  are
1399         treated as a number, giving eight possibilities. Currently only six are         treated as a number, giving eight possibilities. Currently only six are
1400         used  (default  plus the five values above). This means that if you set         used (default plus the five values above). This means that if  you  set
1401         more than one newline option, the combination may or may not be  sensi-         more  than one newline option, the combination may or may not be sensi-
1402         ble. For example, PCRE_NEWLINE_CR with PCRE_NEWLINE_LF is equivalent to         ble. For example, PCRE_NEWLINE_CR with PCRE_NEWLINE_LF is equivalent to
1403         PCRE_NEWLINE_CRLF, but other combinations may yield unused numbers  and         PCRE_NEWLINE_CRLF,  but other combinations may yield unused numbers and
1404         cause an error.         cause an error.
1405    
1406         The  only  time  that a line break in a pattern is specially recognized         The only time that a line break in a pattern  is  specially  recognized
1407         when compiling is when PCRE_EXTENDED is set. CR and LF  are  whitespace         when  compiling  is when PCRE_EXTENDED is set. CR and LF are whitespace
1408         characters,  and so are ignored in this mode. Also, an unescaped # out-         characters, and so are ignored in this mode. Also, an unescaped #  out-
1409         side a character class indicates a comment that lasts until  after  the         side  a  character class indicates a comment that lasts until after the
1410         next  line break sequence. In other circumstances, line break sequences         next line break sequence. In other circumstances, line break  sequences
1411         in patterns are treated as literal data.         in patterns are treated as literal data.
1412    
1413         The newline option that is set at compile time becomes the default that         The newline option that is set at compile time becomes the default that
# Line 1393  COMPILING A PATTERN Line 1416  COMPILING A PATTERN
1416           PCRE_NO_AUTO_CAPTURE           PCRE_NO_AUTO_CAPTURE
1417    
1418         If this option is set, it disables the use of numbered capturing paren-         If this option is set, it disables the use of numbered capturing paren-
1419         theses in the pattern. Any opening parenthesis that is not followed  by         theses  in the pattern. Any opening parenthesis that is not followed by
1420         ?  behaves as if it were followed by ?: but named parentheses can still         ? behaves as if it were followed by ?: but named parentheses can  still
1421         be used for capturing (and they acquire  numbers  in  the  usual  way).         be  used  for  capturing  (and  they acquire numbers in the usual way).
1422         There is no equivalent of this option in Perl.         There is no equivalent of this option in Perl.
1423    
1424           NO_START_OPTIMIZE           NO_START_OPTIMIZE
1425    
1426         This  is an option that acts at matching time; that is, it is really an         This is an option that acts at matching time; that is, it is really  an
1427         option for pcre_exec() or pcre_dfa_exec(). If  it  is  set  at  compile         option  for  pcre_exec()  or  pcre_dfa_exec().  If it is set at compile
1428         time,  it is remembered with the compiled pattern and assumed at match-         time, it is remembered with the compiled pattern and assumed at  match-
1429         ing time. For details  see  the  discussion  of  PCRE_NO_START_OPTIMIZE         ing  time.  For  details  see  the discussion of PCRE_NO_START_OPTIMIZE
1430         below.         below.
1431    
1432           PCRE_UCP           PCRE_UCP
1433    
1434         This  option changes the way PCRE processes \B, \b, \D, \d, \S, \s, \W,         This option changes the way PCRE processes \B, \b, \D, \d, \S, \s,  \W,
1435         \w, and some of the POSIX character classes.  By  default,  only  ASCII         \w,  and  some  of  the POSIX character classes. By default, only ASCII
1436         characters  are  recognized, but if PCRE_UCP is set, Unicode properties         characters are recognized, but if PCRE_UCP is set,  Unicode  properties
1437         are used instead to classify characters. More details are given in  the         are  used instead to classify characters. More details are given in the
1438         section  on generic character types in the pcrepattern page. If you set         section on generic character types in the pcrepattern page. If you  set
1439         PCRE_UCP, matching one of the items it affects takes much  longer.  The         PCRE_UCP,  matching  one of the items it affects takes much longer. The
1440         option  is  available only if PCRE has been compiled with Unicode prop-         option is available only if PCRE has been compiled with  Unicode  prop-
1441         erty support.         erty support.
1442    
1443           PCRE_UNGREEDY           PCRE_UNGREEDY
1444    
1445         This option inverts the "greediness" of the quantifiers  so  that  they         This  option  inverts  the "greediness" of the quantifiers so that they
1446         are  not greedy by default, but become greedy if followed by "?". It is         are not greedy by default, but become greedy if followed by "?". It  is
1447         not compatible with Perl. It can also be set by a (?U)  option  setting         not  compatible  with Perl. It can also be set by a (?U) option setting
1448         within the pattern.         within the pattern.
1449    
1450           PCRE_UTF8           PCRE_UTF8
1451    
1452         This  option  causes PCRE to regard both the pattern and the subject as         This option causes PCRE to regard both the pattern and the  subject  as
1453         strings of UTF-8 characters instead of single-byte  character  strings.         strings  of  UTF-8 characters instead of single-byte character strings.
1454         However,  it is available only when PCRE is built to include UTF-8 sup-         However, it is available only when PCRE is built to include UTF-8  sup-
1455         port. If not, the use of this option provokes an error. Details of  how         port.  If not, the use of this option provokes an error. Details of how
1456         this  option  changes the behaviour of PCRE are given in the section on         this option changes the behaviour of PCRE are given in the  section  on
1457         UTF-8 support in the main pcre page.         UTF-8 support in the main pcre page.
1458    
1459           PCRE_NO_UTF8_CHECK           PCRE_NO_UTF8_CHECK
1460    
1461         When PCRE_UTF8 is set, the validity of the pattern as a UTF-8 string is         When PCRE_UTF8 is set, the validity of the pattern as a UTF-8 string is
1462         automatically  checked.  There  is  a  discussion about the validity of         automatically checked. There is a  discussion  about  the  validity  of
1463         UTF-8 strings in the main pcre page. If an invalid  UTF-8  sequence  of         UTF-8  strings  in  the main pcre page. If an invalid UTF-8 sequence of
1464         bytes  is  found,  pcre_compile() returns an error. If you already know         bytes is found, pcre_compile() returns an error. If  you  already  know
1465         that your pattern is valid, and you want to skip this check for perfor-         that your pattern is valid, and you want to skip this check for perfor-
1466         mance  reasons,  you  can set the PCRE_NO_UTF8_CHECK option. When it is         mance reasons, you can set the PCRE_NO_UTF8_CHECK option.  When  it  is
1467         set, the effect of passing an invalid UTF-8  string  as  a  pattern  is         set,  the  effect  of  passing  an invalid UTF-8 string as a pattern is
1468         undefined.  It  may  cause your program to crash. Note that this option         undefined. It may cause your program to crash. Note  that  this  option
1469         can also be passed to pcre_exec() and pcre_dfa_exec(), to suppress  the         can  also be passed to pcre_exec() and pcre_dfa_exec(), to suppress the
1470         UTF-8 validity checking of subject strings.         UTF-8 validity checking of subject strings.
1471    
1472    
1473  COMPILATION ERROR CODES  COMPILATION ERROR CODES
1474    
1475         The  following  table  lists  the  error  codes than may be returned by         The following table lists the error  codes  than  may  be  returned  by
1476         pcre_compile2(), along with the error messages that may be returned  by         pcre_compile2(),  along with the error messages that may be returned by
1477         both  compiling functions. As PCRE has developed, some error codes have         both compiling functions. As PCRE has developed, some error codes  have
1478         fallen out of use. To avoid confusion, they have not been re-used.         fallen out of use. To avoid confusion, they have not been re-used.
1479    
1480            0  no error            0  no error
# Line 1526  COMPILATION ERROR CODES Line 1549  COMPILATION ERROR CODES
1549           66  (*MARK) must have an argument           66  (*MARK) must have an argument
1550           67  this version of PCRE is not compiled with PCRE_UCP support           67  this version of PCRE is not compiled with PCRE_UCP support
1551    
1552         The numbers 32 and 10000 in errors 48 and 49  are  defaults;  different         The  numbers  32  and 10000 in errors 48 and 49 are defaults; different
1553         values may be used if the limits were changed when PCRE was built.         values may be used if the limits were changed when PCRE was built.
1554    
1555    
# Line 1535  STUDYING A PATTERN Line 1558  STUDYING A PATTERN
1558         pcre_extra *pcre_study(const pcre *code, int options         pcre_extra *pcre_study(const pcre *code, int options
1559              const char **errptr);              const char **errptr);
1560    
1561         If  a  compiled  pattern is going to be used several times, it is worth         If a compiled pattern is going to be used several times,  it  is  worth
1562         spending more time analyzing it in order to speed up the time taken for         spending more time analyzing it in order to speed up the time taken for
1563         matching.  The function pcre_study() takes a pointer to a compiled pat-         matching. The function pcre_study() takes a pointer to a compiled  pat-
1564         tern as its first argument. If studying the pattern produces additional         tern as its first argument. If studying the pattern produces additional
1565         information  that  will  help speed up matching, pcre_study() returns a         information that will help speed up matching,  pcre_study()  returns  a
1566         pointer to a pcre_extra block, in which the study_data field points  to         pointer  to a pcre_extra block, in which the study_data field points to
1567         the results of the study.         the results of the study.
1568    
1569         The  returned  value  from  pcre_study()  can  be  passed  directly  to         The  returned  value  from  pcre_study()  can  be  passed  directly  to
1570         pcre_exec() or pcre_dfa_exec(). However, a pcre_extra block  also  con-         pcre_exec()  or  pcre_dfa_exec(). However, a pcre_extra block also con-
1571         tains  other  fields  that can be set by the caller before the block is         tains other fields that can be set by the caller before  the  block  is
1572         passed; these are described below in the section on matching a pattern.         passed; these are described below in the section on matching a pattern.
1573    
1574         If studying the  pattern  does  not  produce  any  useful  information,         If  studying  the  pattern  does  not  produce  any useful information,
1575         pcre_study() returns NULL. In that circumstance, if the calling program         pcre_study() returns NULL. In that circumstance, if the calling program
1576         wants  to  pass  any  of   the   other   fields   to   pcre_exec()   or         wants   to   pass   any   of   the   other  fields  to  pcre_exec()  or
1577         pcre_dfa_exec(), it must set up its own pcre_extra block.         pcre_dfa_exec(), it must set up its own pcre_extra block.
1578    
1579         The  second  argument of pcre_study() contains option bits. At present,         The second argument of pcre_study() contains option bits.  At  present,
1580         no options are defined, and this argument should always be zero.         no options are defined, and this argument should always be zero.
1581    
1582         The third argument for pcre_study() is a pointer for an error  message.         The  third argument for pcre_study() is a pointer for an error message.
1583         If  studying  succeeds  (even  if no data is returned), the variable it         If studying succeeds (even if no data is  returned),  the  variable  it
1584         points to is set to NULL. Otherwise it is set to  point  to  a  textual         points  to  is  set  to NULL. Otherwise it is set to point to a textual
1585         error message. This is a static string that is part of the library. You         error message. This is a static string that is part of the library. You
1586         must not try to free it. You should test the  error  pointer  for  NULL         must  not  try  to  free it. You should test the error pointer for NULL
1587         after calling pcre_study(), to be sure that it has run successfully.         after calling pcre_study(), to be sure that it has run successfully.
1588    
1589         This is a typical call to pcre_study():         This is a typical call to pcre_study():
# Line 1574  STUDYING A PATTERN Line 1597  STUDYING A PATTERN
1597         Studying a pattern does two things: first, a lower bound for the length         Studying a pattern does two things: first, a lower bound for the length
1598         of subject string that is needed to match the pattern is computed. This         of subject string that is needed to match the pattern is computed. This
1599         does not mean that there are any strings of that length that match, but         does not mean that there are any strings of that length that match, but
1600         it does guarantee that no shorter strings match. The value is  used  by         it  does  guarantee that no shorter strings match. The value is used by
1601         pcre_exec()  and  pcre_dfa_exec()  to  avoid  wasting time by trying to         pcre_exec() and pcre_dfa_exec() to avoid  wasting  time  by  trying  to
1602         match strings that are shorter than the lower bound. You can  find  out         match  strings  that are shorter than the lower bound. You can find out
1603         the value in a calling program via the pcre_fullinfo() function.         the value in a calling program via the pcre_fullinfo() function.
1604    
1605         Studying a pattern is also useful for non-anchored patterns that do not         Studying a pattern is also useful for non-anchored patterns that do not
1606         have a single fixed starting character. A bitmap of  possible  starting         have  a  single fixed starting character. A bitmap of possible starting
1607         bytes  is  created. This speeds up finding a position in the subject at         bytes is created. This speeds up finding a position in the  subject  at
1608         which to start matching.         which to start matching.
1609    
1610         The two optimizations just described can be  disabled  by  setting  the         The  two  optimizations  just  described can be disabled by setting the
1611         PCRE_NO_START_OPTIMIZE    option    when    calling    pcre_exec()   or         PCRE_NO_START_OPTIMIZE   option    when    calling    pcre_exec()    or
1612         pcre_dfa_exec(). You might want to do this  if  your  pattern  contains         pcre_dfa_exec().  You  might  want  to do this if your pattern contains
1613         callouts  or  (*MARK),  and you want to make use of these facilities in         callouts or (*MARK), and you want to make use of  these  facilities  in
1614         cases where matching fails. See the discussion  of  PCRE_NO_START_OPTI-         cases  where  matching fails. See the discussion of PCRE_NO_START_OPTI-
1615         MIZE below.         MIZE below.
1616    
1617    
1618  LOCALE SUPPORT  LOCALE SUPPORT
1619    
1620         PCRE  handles  caseless matching, and determines whether characters are         PCRE handles caseless matching, and determines whether  characters  are
1621         letters, digits, or whatever, by reference to a set of tables,  indexed         letters,  digits, or whatever, by reference to a set of tables, indexed
1622         by  character  value.  When running in UTF-8 mode, this applies only to         by character value. When running in UTF-8 mode, this  applies  only  to
1623         characters with codes less than 128. By  default,  higher-valued  codes         characters  with  codes  less than 128. By default, higher-valued codes
1624         never match escapes such as \w or \d, but they can be tested with \p if         never match escapes such as \w or \d, but they can be tested with \p if
1625         PCRE is built with Unicode character property  support.  Alternatively,         PCRE  is  built with Unicode character property support. Alternatively,
1626         the  PCRE_UCP  option  can  be  set at compile time; this causes \w and         the PCRE_UCP option can be set at compile  time;  this  causes  \w  and
1627         friends to use Unicode property support instead of built-in tables. The         friends to use Unicode property support instead of built-in tables. The
1628         use of locales with Unicode is discouraged. If you are handling charac-         use of locales with Unicode is discouraged. If you are handling charac-
1629         ters with codes greater than 128, you should either use UTF-8 and  Uni-         ters  with codes greater than 128, you should either use UTF-8 and Uni-
1630         code, or use locales, but not try to mix the two.         code, or use locales, but not try to mix the two.
1631    
1632         PCRE  contains  an  internal set of tables that are used when the final         PCRE contains an internal set of tables that are used  when  the  final
1633         argument of pcre_compile() is  NULL.  These  are  sufficient  for  many         argument  of  pcre_compile()  is  NULL.  These  are sufficient for many
1634         applications.  Normally, the internal tables recognize only ASCII char-         applications.  Normally, the internal tables recognize only ASCII char-
1635         acters. However, when PCRE is built, it is possible to cause the inter-         acters. However, when PCRE is built, it is possible to cause the inter-
1636         nal tables to be rebuilt in the default "C" locale of the local system,         nal tables to be rebuilt in the default "C" locale of the local system,
1637         which may cause them to be different.         which may cause them to be different.
1638    
1639         The internal tables can always be overridden by tables supplied by  the         The  internal tables can always be overridden by tables supplied by the
1640         application that calls PCRE. These may be created in a different locale         application that calls PCRE. These may be created in a different locale
1641         from the default. As more and more applications change  to  using  Uni-         from  the  default.  As more and more applications change to using Uni-
1642         code, the need for this locale support is expected to die away.         code, the need for this locale support is expected to die away.
1643    
1644         External  tables  are  built by calling the pcre_maketables() function,         External tables are built by calling  the  pcre_maketables()  function,
1645         which has no arguments, in the relevant locale. The result can then  be         which  has no arguments, in the relevant locale. The result can then be
1646         passed  to  pcre_compile()  or  pcre_exec()  as often as necessary. For         passed to pcre_compile() or pcre_exec()  as  often  as  necessary.  For
1647         example, to build and use tables that are appropriate  for  the  French         example,  to  build  and use tables that are appropriate for the French
1648         locale  (where  accented  characters  with  values greater than 128 are         locale (where accented characters with  values  greater  than  128  are
1649         treated as letters), the following code could be used:         treated as letters), the following code could be used:
1650    
1651           setlocale(LC_CTYPE, "fr_FR");           setlocale(LC_CTYPE, "fr_FR");
1652           tables = pcre_maketables();           tables = pcre_maketables();
1653           re = pcre_compile(..., tables);           re = pcre_compile(..., tables);
1654    
1655         The locale name "fr_FR" is used on Linux and other  Unix-like  systems;         The  locale  name "fr_FR" is used on Linux and other Unix-like systems;
1656         if you are using Windows, the name for the French locale is "french".         if you are using Windows, the name for the French locale is "french".
1657    
1658         When  pcre_maketables()  runs,  the  tables are built in memory that is         When pcre_maketables() runs, the tables are built  in  memory  that  is
1659         obtained via pcre_malloc. It is the caller's responsibility  to  ensure         obtained  via  pcre_malloc. It is the caller's responsibility to ensure
1660         that  the memory containing the tables remains available for as long as         that the memory containing the tables remains available for as long  as
1661         it is needed.         it is needed.
1662    
1663         The pointer that is passed to pcre_compile() is saved with the compiled         The pointer that is passed to pcre_compile() is saved with the compiled
1664         pattern,  and the same tables are used via this pointer by pcre_study()         pattern, and the same tables are used via this pointer by  pcre_study()
1665         and normally also by pcre_exec(). Thus, by default, for any single pat-         and normally also by pcre_exec(). Thus, by default, for any single pat-
1666         tern, compilation, studying and matching all happen in the same locale,         tern, compilation, studying and matching all happen in the same locale,
1667         but different patterns can be compiled in different locales.         but different patterns can be compiled in different locales.
1668    
1669         It is possible to pass a table pointer or NULL (indicating the  use  of         It  is  possible to pass a table pointer or NULL (indicating the use of
1670         the  internal  tables)  to  pcre_exec(). Although not intended for this         the internal tables) to pcre_exec(). Although  not  intended  for  this
1671         purpose, this facility could be used to match a pattern in a  different         purpose,  this facility could be used to match a pattern in a different
1672         locale from the one in which it was compiled. Passing table pointers at         locale from the one in which it was compiled. Passing table pointers at
1673         run time is discussed below in the section on matching a pattern.         run time is discussed below in the section on matching a pattern.
1674    
# Line 1655  INFORMATION ABOUT A PATTERN Line 1678  INFORMATION ABOUT A PATTERN
1678         int pcre_fullinfo(const pcre *code, const pcre_extra *extra,         int pcre_fullinfo(const pcre *code, const pcre_extra *extra,
1679              int what, void *where);              int what, void *where);
1680    
1681         The pcre_fullinfo() function returns information about a compiled  pat-         The  pcre_fullinfo() function returns information about a compiled pat-
1682         tern. It replaces the obsolete pcre_info() function, which is neverthe-         tern. It replaces the obsolete pcre_info() function, which is neverthe-
1683         less retained for backwards compability (and is documented below).         less retained for backwards compability (and is documented below).
1684    
1685         The first argument for pcre_fullinfo() is a  pointer  to  the  compiled         The  first  argument  for  pcre_fullinfo() is a pointer to the compiled
1686         pattern.  The second argument is the result of pcre_study(), or NULL if         pattern. The second argument is the result of pcre_study(), or NULL  if
1687         the pattern was not studied. The third argument specifies  which  piece         the  pattern  was not studied. The third argument specifies which piece
1688         of  information  is required, and the fourth argument is a pointer to a         of information is required, and the fourth argument is a pointer  to  a
1689         variable to receive the data. The yield of the  function  is  zero  for         variable  to  receive  the  data. The yield of the function is zero for
1690         success, or one of the following negative numbers:         success, or one of the following negative numbers:
1691    
1692           PCRE_ERROR_NULL       the argument code was NULL           PCRE_ERROR_NULL       the argument code was NULL
# Line 1671  INFORMATION ABOUT A PATTERN Line 1694  INFORMATION ABOUT A PATTERN
1694           PCRE_ERROR_BADMAGIC   the "magic number" was not found           PCRE_ERROR_BADMAGIC   the "magic number" was not found
1695           PCRE_ERROR_BADOPTION  the value of what was invalid           PCRE_ERROR_BADOPTION  the value of what was invalid
1696    
1697         The  "magic  number" is placed at the start of each compiled pattern as         The "magic number" is placed at the start of each compiled  pattern  as
1698         an simple check against passing an arbitrary memory pointer. Here is  a         an  simple check against passing an arbitrary memory pointer. Here is a
1699         typical  call  of pcre_fullinfo(), to obtain the length of the compiled         typical call of pcre_fullinfo(), to obtain the length of  the  compiled
1700         pattern:         pattern:
1701    
1702           int rc;           int rc;
# Line 1684  INFORMATION ABOUT A PATTERN Line 1707  INFORMATION ABOUT A PATTERN
1707             PCRE_INFO_SIZE,   /* what is required */             PCRE_INFO_SIZE,   /* what is required */
1708             &length);         /* where to put the data */             &length);         /* where to put the data */
1709    
1710         The possible values for the third argument are defined in  pcre.h,  and         The  possible  values for the third argument are defined in pcre.h, and
1711         are as follows:         are as follows:
1712    
1713           PCRE_INFO_BACKREFMAX           PCRE_INFO_BACKREFMAX
1714    
1715         Return  the  number  of  the highest back reference in the pattern. The         Return the number of the highest back reference  in  the  pattern.  The
1716         fourth argument should point to an int variable. Zero  is  returned  if         fourth  argument  should  point to an int variable. Zero is returned if
1717         there are no back references.         there are no back references.
1718    
1719           PCRE_INFO_CAPTURECOUNT           PCRE_INFO_CAPTURECOUNT
1720    
1721         Return  the  number of capturing subpatterns in the pattern. The fourth         Return the number of capturing subpatterns in the pattern.  The  fourth
1722         argument should point to an int variable.         argument should point to an int variable.
1723    
1724           PCRE_INFO_DEFAULT_TABLES           PCRE_INFO_DEFAULT_TABLES
1725    
1726         Return a pointer to the internal default character tables within  PCRE.         Return  a pointer to the internal default character tables within PCRE.
1727         The  fourth  argument should point to an unsigned char * variable. This         The fourth argument should point to an unsigned char *  variable.  This
1728         information call is provided for internal use by the pcre_study() func-         information call is provided for internal use by the pcre_study() func-
1729         tion.  External  callers  can  cause PCRE to use its internal tables by         tion. External callers can cause PCRE to use  its  internal  tables  by
1730         passing a NULL table pointer.         passing a NULL table pointer.
1731    
1732           PCRE_INFO_FIRSTBYTE           PCRE_INFO_FIRSTBYTE
1733    
1734         Return information about the first byte of any matched  string,  for  a         Return  information  about  the first byte of any matched string, for a
1735         non-anchored  pattern. The fourth argument should point to an int vari-         non-anchored pattern. The fourth argument should point to an int  vari-
1736         able. (This option used to be called PCRE_INFO_FIRSTCHAR; the old  name         able.  (This option used to be called PCRE_INFO_FIRSTCHAR; the old name
1737         is still recognized for backwards compatibility.)         is still recognized for backwards compatibility.)
1738    
1739         If  there  is  a  fixed first byte, for example, from a pattern such as         If there is a fixed first byte, for example, from  a  pattern  such  as
1740         (cat|cow|coyote), its value is returned. Otherwise, if either         (cat|cow|coyote), its value is returned. Otherwise, if either
1741    
1742         (a) the pattern was compiled with the PCRE_MULTILINE option, and  every         (a)  the pattern was compiled with the PCRE_MULTILINE option, and every
1743         branch starts with "^", or         branch starts with "^", or
1744    
1745         (b) every branch of the pattern starts with ".*" and PCRE_DOTALL is not         (b) every branch of the pattern starts with ".*" and PCRE_DOTALL is not
1746         set (if it were set, the pattern would be anchored),         set (if it were set, the pattern would be anchored),
1747    
1748         -1 is returned, indicating that the pattern matches only at  the  start         -1  is  returned, indicating that the pattern matches only at the start
1749         of  a  subject string or after any newline within the string. Otherwise         of a subject string or after any newline within the  string.  Otherwise
1750         -2 is returned. For anchored patterns, -2 is returned.         -2 is returned. For anchored patterns, -2 is returned.
1751    
1752           PCRE_INFO_FIRSTTABLE           PCRE_INFO_FIRSTTABLE
1753    
1754         If the pattern was studied, and this resulted in the construction of  a         If  the pattern was studied, and this resulted in the construction of a
1755         256-bit table indicating a fixed set of bytes for the first byte in any         256-bit table indicating a fixed set of bytes for the first byte in any
1756         matching string, a pointer to the table is returned. Otherwise NULL  is         matching  string, a pointer to the table is returned. Otherwise NULL is
1757         returned.  The fourth argument should point to an unsigned char * vari-         returned. The fourth argument should point to an unsigned char *  vari-
1758         able.         able.
1759    
1760           PCRE_INFO_HASCRORLF           PCRE_INFO_HASCRORLF
1761    
1762         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
1763         characters,  otherwise  0.  The  fourth argument should point to an int         characters, otherwise 0. The fourth argument should  point  to  an  int
1764         variable. An explicit match is either a literal CR or LF character,  or         variable.  An explicit match is either a literal CR or LF character, or
1765         \r or \n.         \r or \n.
1766    
1767           PCRE_INFO_JCHANGED           PCRE_INFO_JCHANGED
1768    
1769         Return  1  if  the (?J) or (?-J) option setting is used in the pattern,         Return 1 if the (?J) or (?-J) option setting is used  in  the  pattern,
1770         otherwise 0. The fourth argument should point to an int variable.  (?J)         otherwise  0. The fourth argument should point to an int variable. (?J)
1771         and (?-J) set and unset the local PCRE_DUPNAMES option, respectively.         and (?-J) set and unset the local PCRE_DUPNAMES option, respectively.
1772    
1773           PCRE_INFO_LASTLITERAL           PCRE_INFO_LASTLITERAL
1774    
1775         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
1776         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
1777         recorded. The fourth argument should point to an int variable. If there         recorded. The fourth argument should point to an int variable. If there
1778         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
1779         byte  is  recorded only if it follows something of variable length. For         byte is recorded only if it follows something of variable  length.  For
1780         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
1781         /^a\dz\d/ the returned value is -1.         /^a\dz\d/ the returned value is -1.
1782    
1783           PCRE_INFO_MINLENGTH           PCRE_INFO_MINLENGTH
1784    
1785         If  the  pattern  was studied and a minimum length for matching subject         If the pattern was studied and a minimum length  for  matching  subject
1786         strings was computed, its value is  returned.  Otherwise  the  returned         strings  was  computed,  its  value is returned. Otherwise the returned
1787         value  is  -1. The value is a number of characters, not bytes (this may         value is -1. The value is a number of characters, not bytes  (this  may
1788         be relevant in UTF-8 mode). The fourth argument should point to an  int         be  relevant in UTF-8 mode). The fourth argument should point to an int
1789         variable.  A  non-negative  value is a lower bound to the length of any         variable. A non-negative value is a lower bound to the  length  of  any
1790         matching string. There may not be any strings of that  length  that  do         matching  string.  There  may not be any strings of that length that do
1791         actually match, but every string that does match is at least that long.         actually match, but every string that does match is at least that long.
1792    
1793           PCRE_INFO_NAMECOUNT           PCRE_INFO_NAMECOUNT
1794           PCRE_INFO_NAMEENTRYSIZE           PCRE_INFO_NAMEENTRYSIZE
1795           PCRE_INFO_NAMETABLE           PCRE_INFO_NAMETABLE
1796    
1797         PCRE  supports the use of named as well as numbered capturing parenthe-         PCRE supports the use of named as well as numbered capturing  parenthe-
1798         ses. The names are just an additional way of identifying the  parenthe-         ses.  The names are just an additional way of identifying the parenthe-
1799         ses, which still acquire numbers. Several convenience functions such as         ses, which still acquire numbers. Several convenience functions such as
1800         pcre_get_named_substring() are provided for  extracting  captured  sub-         pcre_get_named_substring()  are  provided  for extracting captured sub-
1801         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
1802         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
1803         pointers in the output vector (described with pcre_exec() below). To do         pointers in the output vector (described with pcre_exec() below). To do
1804         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
1805         described by these three values.         described by these three values.
1806    
1807         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
1808         gives the number of entries, and PCRE_INFO_NAMEENTRYSIZE gives the size         gives the number of entries, and PCRE_INFO_NAMEENTRYSIZE gives the size
1809         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
1810         depends on the length of the longest name. PCRE_INFO_NAMETABLE  returns         depends  on the length of the longest name. PCRE_INFO_NAMETABLE returns
1811         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
1812         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-
1813         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-
1814         sponding name, zero terminated.         sponding name, zero terminated.
1815    
1816         The names are in alphabetical order. Duplicate names may appear if  (?|         The  names are in alphabetical order. Duplicate names may appear if (?|
1817         is used to create multiple groups with the same number, as described in         is used to create multiple groups with the same number, as described in
1818         the section on duplicate subpattern numbers in  the  pcrepattern  page.         the  section  on  duplicate subpattern numbers in the pcrepattern page.
1819         Duplicate  names  for  subpatterns with different numbers are permitted         Duplicate names for subpatterns with different  numbers  are  permitted
1820         only if PCRE_DUPNAMES is set. In all cases  of  duplicate  names,  they         only  if  PCRE_DUPNAMES  is  set. In all cases of duplicate names, they
1821         appear  in  the table in the order in which they were found in the pat-         appear in the table in the order in which they were found in  the  pat-
1822         tern. In the absence of (?| this is the  order  of  increasing  number;         tern.  In  the  absence  of (?| this is the order of increasing number;
1823         when (?| is used this is not necessarily the case because later subpat-         when (?| is used this is not necessarily the case because later subpat-
1824         terns may have lower numbers.         terns may have lower numbers.
1825    
1826         As a simple example of the name/number table,  consider  the  following         As  a  simple  example of the name/number table, consider the following
1827         pattern  (assume  PCRE_EXTENDED is set, so white space - including new-         pattern (assume PCRE_EXTENDED is set, so white space -  including  new-
1828         lines - is ignored):         lines - is ignored):
1829    
1830           (?<date> (?<year>(\d\d)?\d\d) -           (?<date> (?<year>(\d\d)?\d\d) -
1831           (?<month>\d\d) - (?<day>\d\d) )           (?<month>\d\d) - (?<day>\d\d) )
1832    
1833         There are four named subpatterns, so the table has  four  entries,  and         There  are  four  named subpatterns, so the table has four entries, and
1834         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,
1835         with non-printing bytes shows in hexadecimal, and undefined bytes shown         with non-printing bytes shows in hexadecimal, and undefined bytes shown
1836         as ??:         as ??:
1837    
# Line 1817  INFORMATION ABOUT A PATTERN Line 1840  INFORMATION ABOUT A PATTERN
1840           00 04 m  o  n  t  h  00           00 04 m  o  n  t  h  00
1841           00 02 y  e  a  r  00 ??           00 02 y  e  a  r  00 ??
1842    
1843         When  writing  code  to  extract  data from named subpatterns using the         When writing code to extract data  from  named  subpatterns  using  the
1844         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
1845         to be different for each compiled pattern.         to be different for each compiled pattern.
1846    
1847           PCRE_INFO_OKPARTIAL           PCRE_INFO_OKPARTIAL
1848    
1849         Return  1  if  the  pattern  can  be  used  for  partial  matching with         Return 1  if  the  pattern  can  be  used  for  partial  matching  with
1850         pcre_exec(), otherwise 0. The fourth argument should point  to  an  int         pcre_exec(),  otherwise  0.  The fourth argument should point to an int
1851         variable.  From  release  8.00,  this  always  returns  1,  because the         variable. From  release  8.00,  this  always  returns  1,  because  the
1852         restrictions that previously applied  to  partial  matching  have  been         restrictions  that  previously  applied  to  partial matching have been
1853         lifted.  The  pcrepartial documentation gives details of partial match-         lifted. The pcrepartial documentation gives details of  partial  match-
1854         ing.         ing.
1855    
1856           PCRE_INFO_OPTIONS           PCRE_INFO_OPTIONS
1857    
1858         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
1859         fourth  argument  should  point to an unsigned long int variable. These         fourth argument should point to an unsigned long  int  variable.  These
1860         option bits are those specified in the call to pcre_compile(), modified         option bits are those specified in the call to pcre_compile(), modified
1861         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
1862         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
1863         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
1864         the PCRE_EXTENDED option, the result is PCRE_CASELESS,  PCRE_MULTILINE,         the  PCRE_EXTENDED option, the result is PCRE_CASELESS, PCRE_MULTILINE,
1865         and PCRE_EXTENDED.         and PCRE_EXTENDED.
1866    
1867         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
1868         alternatives begin with one of the following:         alternatives begin with one of the following:
1869    
1870           ^     unless PCRE_MULTILINE is set           ^     unless PCRE_MULTILINE is set
# Line 1855  INFORMATION ABOUT A PATTERN Line 1878  INFORMATION ABOUT A PATTERN
1878    
1879           PCRE_INFO_SIZE           PCRE_INFO_SIZE
1880    
1881         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
1882         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
1883         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
1884         size_t variable.         size_t variable.
# Line 1863  INFORMATION ABOUT A PATTERN Line 1886  INFORMATION ABOUT A PATTERN
1886           PCRE_INFO_STUDYSIZE           PCRE_INFO_STUDYSIZE
1887    
1888         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
1889         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
1890         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
1891         created  by  pcre_study().  If pcre_extra is NULL, or there is no study         created by pcre_study(). If pcre_extra is NULL, or there  is  no  study
1892         data, zero is returned. The fourth argument should point  to  a  size_t         data,  zero  is  returned. The fourth argument should point to a size_t
1893         variable.         variable.
1894    
1895    
# Line 1874  OBSOLETE INFO FUNCTION Line 1897  OBSOLETE INFO FUNCTION
1897    
1898         int pcre_info(const pcre *code, int *optptr, int *firstcharptr);         int pcre_info(const pcre *code, int *optptr, int *firstcharptr);
1899    
1900         The  pcre_info()  function is now obsolete because its interface is too         The pcre_info() function is now obsolete because its interface  is  too
1901         restrictive to return all the available data about a compiled  pattern.         restrictive  to return all the available data about a compiled pattern.
1902         New   programs   should  use  pcre_fullinfo()  instead.  The  yield  of         New  programs  should  use  pcre_fullinfo()  instead.  The   yield   of
1903         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-
1904         lowing negative numbers:         lowing negative numbers:
1905    
1906           PCRE_ERROR_NULL       the argument code was NULL           PCRE_ERROR_NULL       the argument code was NULL
1907           PCRE_ERROR_BADMAGIC   the "magic number" was not found           PCRE_ERROR_BADMAGIC   the "magic number" was not found
1908    
1909         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
1910         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
1911         PCRE_INFO_OPTIONS above).         PCRE_INFO_OPTIONS above).
1912    
1913         If  the  pattern  is  not anchored and the firstcharptr argument is not         If the pattern is not anchored and the  firstcharptr  argument  is  not
1914         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
1915         any matched string (see PCRE_INFO_FIRSTBYTE above).         any matched string (see PCRE_INFO_FIRSTBYTE above).
1916    
1917    
# Line 1896  REFERENCE COUNTS Line 1919  REFERENCE COUNTS
1919    
1920         int pcre_refcount(pcre *code, int adjust);         int pcre_refcount(pcre *code, int adjust);
1921    
1922         The  pcre_refcount()  function is used to maintain a reference count in         The pcre_refcount() function is used to maintain a reference  count  in
1923         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
1924         benefit  of  applications  that  operate  in an object-oriented manner,         benefit of applications that  operate  in  an  object-oriented  manner,
1925         where different parts of the application may be using the same compiled         where different parts of the application may be using the same compiled
1926         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.
1927    
1928         When a pattern is compiled, the reference count field is initialized to         When a pattern is compiled, the reference count field is initialized to
1929         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
1930         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
1931         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
1932         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
1933         is outside these limits, it is forced to the appropriate limit value.         is outside these limits, it is forced to the appropriate limit value.
1934    
1935         Except when it is zero, the reference count is not correctly  preserved         Except  when it is zero, the reference count is not correctly preserved
1936         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
1937         whose byte-order is different. (This seems a highly unlikely scenario.)         whose byte-order is different. (This seems a highly unlikely scenario.)
1938    
1939    
# Line 1920  MATCHING A PATTERN: THE TRADITIONAL FUNC Line 1943  MATCHING A PATTERN: THE TRADITIONAL FUNC
1943              const char *subject, int length, int startoffset,              const char *subject, int length, int startoffset,
1944              int options, int *ovector, int ovecsize);              int options, int *ovector, int ovecsize);
1945    
1946         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
1947         compiled  pattern, which is passed in the code argument. If the pattern         compiled pattern, which is passed in the code argument. If the  pattern
1948         was studied, the result of the study should  be  passed  in  the  extra         was  studied,  the  result  of  the study should be passed in the extra
1949         argument.  This  function is the main matching facility of the library,         argument. This function is the main matching facility of  the  library,
1950         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
1951         an  alternative matching function, which is described below in the sec-         an alternative matching function, which is described below in the  sec-
1952         tion about the pcre_dfa_exec() function.         tion about the pcre_dfa_exec() function.
1953    
1954         In most applications, the pattern will have been compiled (and  option-         In  most applications, the pattern will have been compiled (and option-
1955         ally  studied)  in the same process that calls pcre_exec(). However, it         ally studied) in the same process that calls pcre_exec().  However,  it
1956         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
1957         later  in  different processes, possibly even on different hosts. For a         later in different processes, possibly even on different hosts.  For  a
1958         discussion about this, see the pcreprecompile documentation.         discussion about this, see the pcreprecompile documentation.
1959    
1960         Here is an example of a simple call to pcre_exec():         Here is an example of a simple call to pcre_exec():
# Line 1950  MATCHING A PATTERN: THE TRADITIONAL FUNC Line 1973  MATCHING A PATTERN: THE TRADITIONAL FUNC
1973    
1974     Extra data for pcre_exec()     Extra data for pcre_exec()
1975    
1976         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
1977         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
1978         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-
1979         tional  information  in it. The pcre_extra block contains the following         tional information in it. The pcre_extra block contains  the  following
1980         fields (not necessarily in this order):         fields (not necessarily in this order):
1981    
1982           unsigned long int flags;           unsigned long int flags;
# Line 1964  MATCHING A PATTERN: THE TRADITIONAL FUNC Line 1987  MATCHING A PATTERN: THE TRADITIONAL FUNC
1987           const unsigned char *tables;           const unsigned char *tables;
1988           unsigned char **mark;           unsigned char **mark;
1989    
1990         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
1991         are set. The flag bits are:         are set. The flag bits are:
1992    
1993           PCRE_EXTRA_STUDY_DATA           PCRE_EXTRA_STUDY_DATA
# Line 1974  MATCHING A PATTERN: THE TRADITIONAL FUNC Line 1997  MATCHING A PATTERN: THE TRADITIONAL FUNC
1997           PCRE_EXTRA_TABLES           PCRE_EXTRA_TABLES
1998           PCRE_EXTRA_MARK           PCRE_EXTRA_MARK
1999    
2000         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
2001         the pcre_extra block that is returned by  pcre_study(),  together  with         the  pcre_extra  block  that is returned by pcre_study(), together with
2002         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
2003         add to the block by setting the other fields  and  their  corresponding         add  to  the  block by setting the other fields and their corresponding
2004         flag bits.         flag bits.
2005    
2006         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
2007         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
2008         match,  but  which  have  a very large number of possibilities in their         match, but which have a very large number  of  possibilities  in  their
2009         search trees. The classic example is a pattern that uses nested  unlim-         search  trees. The classic example is a pattern that uses nested unlim-
2010         ited repeats.         ited repeats.
2011    
2012         Internally,  PCRE uses a function called match() which it calls repeat-         Internally, PCRE uses a function called match() which it calls  repeat-
2013         edly (sometimes recursively). The limit set by match_limit  is  imposed         edly  (sometimes  recursively). The limit set by match_limit is imposed
2014         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
2015         has the effect of limiting the amount of  backtracking  that  can  take         has  the  effect  of  limiting the amount of backtracking that can take
2016         place. For patterns that are not anchored, the count restarts from zero         place. For patterns that are not anchored, the count restarts from zero
2017         for each position in the subject string.         for each position in the subject string.
2018    
2019         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
2020         default  default  is 10 million, which handles all but the most extreme         default default is 10 million, which handles all but the  most  extreme
2021         cases. You can override the default  by  suppling  pcre_exec()  with  a         cases.  You  can  override  the  default by suppling pcre_exec() with a
2022         pcre_extra     block    in    which    match_limit    is    set,    and         pcre_extra    block    in    which    match_limit    is    set,     and
2023         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
2024         exceeded, pcre_exec() returns PCRE_ERROR_MATCHLIMIT.         exceeded, pcre_exec() returns PCRE_ERROR_MATCHLIMIT.
2025    
2026         The  match_limit_recursion field is similar to match_limit, but instead         The match_limit_recursion field is similar to match_limit, but  instead
2027         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
2028         the  depth  of  recursion. The recursion depth is a smaller number than         the depth of recursion. The recursion depth is a  smaller  number  than
2029         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-
2030         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.
2031    
2032         Limiting  the  recursion  depth  limits the amount of stack that can be         Limiting the recursion depth limits the amount of  stack  that  can  be
2033         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
2034         of the stack, the amount of heap memory that can be used.         of the stack, the amount of heap memory that can be used.
2035    
2036         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
2037         built; the default default  is  the  same  value  as  the  default  for         built;  the  default  default  is  the  same  value  as the default for
2038         match_limit.  You can override the default by suppling pcre_exec() with         match_limit. You can override the default by suppling pcre_exec()  with
2039         a  pcre_extra  block  in  which  match_limit_recursion  is   set,   and         a   pcre_extra   block  in  which  match_limit_recursion  is  set,  and
2040         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
2041         limit is exceeded, pcre_exec() returns PCRE_ERROR_RECURSIONLIMIT.         limit is exceeded, pcre_exec() returns PCRE_ERROR_RECURSIONLIMIT.
2042    
2043         The callout_data field is used in conjunction with the  "callout"  fea-         The  callout_data  field is used in conjunction with the "callout" fea-
2044         ture, and is described in the pcrecallout documentation.         ture, and is described in the pcrecallout documentation.
2045    
2046         The  tables  field  is  used  to  pass  a  character  tables pointer to         The tables field  is  used  to  pass  a  character  tables  pointer  to
2047         pcre_exec(); this overrides the value that is stored with the  compiled         pcre_exec();  this overrides the value that is stored with the compiled
2048         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
2049         custom tables were supplied to pcre_compile() via  its  tableptr  argu-         custom  tables  were  supplied to pcre_compile() via its tableptr argu-
2050         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
2051         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-
2052         using  patterns  that  have been saved after compiling with an external         using patterns that have been saved after compiling  with  an  external
2053         set of tables, because the external tables  might  be  at  a  different         set  of  tables,  because  the  external tables might be at a different
2054         address  when  pcre_exec() is called. See the pcreprecompile documenta-         address when pcre_exec() is called. See the  pcreprecompile  documenta-
2055         tion for a discussion of saving compiled patterns for later use.         tion for a discussion of saving compiled patterns for later use.
2056    
2057         If PCRE_EXTRA_MARK is set in the flags field, the mark  field  must  be         If  PCRE_EXTRA_MARK  is  set in the flags field, the mark field must be
2058         set  to  point  to a char * variable. If the pattern contains any back-         set to point to a char * variable. If the pattern  contains  any  back-
2059         tracking control verbs such as (*MARK:NAME), and the execution ends  up         tracking  control verbs such as (*MARK:NAME), and the execution ends up
2060         with  a  name  to  pass back, a pointer to the name string (zero termi-         with a name to pass back, a pointer to the  name  string  (zero  termi-
2061         nated) is placed in the variable pointed to  by  the  mark  field.  The         nated)  is  placed  in  the  variable pointed to by the mark field. The
2062         names  are  within  the  compiled pattern; if you wish to retain such a         names are within the compiled pattern; if you wish  to  retain  such  a
2063         name you must copy it before freeing the memory of a compiled  pattern.         name  you must copy it before freeing the memory of a compiled pattern.
2064         If  there  is no name to pass back, the variable pointed to by the mark         If there is no name to pass back, the variable pointed to by  the  mark
2065         field set to NULL. For details of the backtracking control  verbs,  see         field  set  to NULL. For details of the backtracking control verbs, see
2066         the section entitled "Backtracking control" in the pcrepattern documen-         the section entitled "Backtracking control" in the pcrepattern documen-
2067         tation.         tation.
2068    
2069     Option bits for pcre_exec()     Option bits for pcre_exec()
2070    
2071         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.
2072         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,
2073         PCRE_NOTBOL,   PCRE_NOTEOL,    PCRE_NOTEMPTY,    PCRE_NOTEMPTY_ATSTART,         PCRE_NOTBOL,    PCRE_NOTEOL,    PCRE_NOTEMPTY,   PCRE_NOTEMPTY_ATSTART,
2074         PCRE_NO_START_OPTIMIZE,   PCRE_NO_UTF8_CHECK,   PCRE_PARTIAL_SOFT,  and         PCRE_NO_START_OPTIMIZE,  PCRE_NO_UTF8_CHECK,   PCRE_PARTIAL_SOFT,   and
2075         PCRE_PARTIAL_HARD.         PCRE_PARTIAL_HARD.
2076    
2077           PCRE_ANCHORED           PCRE_ANCHORED
2078    
2079         The PCRE_ANCHORED option limits pcre_exec() to matching  at  the  first         The  PCRE_ANCHORED  option  limits pcre_exec() to matching at the first
2080         matching  position.  If  a  pattern was compiled with PCRE_ANCHORED, or         matching position. If a pattern was  compiled  with  PCRE_ANCHORED,  or
2081         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
2082         unachored at matching time.         unachored at matching time.
2083    
2084           PCRE_BSR_ANYCRLF           PCRE_BSR_ANYCRLF
2085           PCRE_BSR_UNICODE           PCRE_BSR_UNICODE
2086    
2087         These options (which are mutually exclusive) control what the \R escape         These options (which are mutually exclusive) control what the \R escape
2088         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,
2089         or  to  match  any Unicode newline sequence. These options override the         or to match any Unicode newline sequence. These  options  override  the
2090         choice that was made or defaulted when the pattern was compiled.         choice that was made or defaulted when the pattern was compiled.
2091    
2092           PCRE_NEWLINE_CR           PCRE_NEWLINE_CR
# Line 2072  MATCHING A PATTERN: THE TRADITIONAL FUNC Line 2095  MATCHING A PATTERN: THE TRADITIONAL FUNC
2095           PCRE_NEWLINE_ANYCRLF           PCRE_NEWLINE_ANYCRLF
2096           PCRE_NEWLINE_ANY           PCRE_NEWLINE_ANY
2097    
2098         These options override  the  newline  definition  that  was  chosen  or         These  options  override  the  newline  definition  that  was chosen or
2099         defaulted  when the pattern was compiled. For details, see the descrip-         defaulted when the pattern was compiled. For details, see the  descrip-
2100         tion of pcre_compile()  above.  During  matching,  the  newline  choice         tion  of  pcre_compile()  above.  During  matching,  the newline choice
2101         affects  the  behaviour  of the dot, circumflex, and dollar metacharac-         affects the behaviour of the dot, circumflex,  and  dollar  metacharac-
2102         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
2103         match failure for an unanchored pattern.         match failure for an unanchored pattern.
2104    
2105         When  PCRE_NEWLINE_CRLF,  PCRE_NEWLINE_ANYCRLF,  or PCRE_NEWLINE_ANY is         When PCRE_NEWLINE_CRLF, PCRE_NEWLINE_ANYCRLF,  or  PCRE_NEWLINE_ANY  is
2106         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-
2107         rent  position  is  at  a  CRLF  sequence,  and the pattern contains no         rent position is at a  CRLF  sequence,  and  the  pattern  contains  no
2108         explicit matches for  CR  or  LF  characters,  the  match  position  is         explicit  matches  for  CR  or  LF  characters,  the  match position is
2109         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
2110         CRLF.         CRLF.
2111    
2112         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
2113         expected.  For  example,  if  the  pattern  is .+A (and the PCRE_DOTALL         expected. For example, if the  pattern  is  .+A  (and  the  PCRE_DOTALL
2114         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
2115         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.
2116         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-
2117         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-
2118         acter after the first failure.         acter after the first failure.
2119    
2120         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
2121         those  characters,  or  one  of the \r or \n escape sequences. Implicit         those characters, or one of the \r or  \n  escape  sequences.  Implicit
2122         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
2123         LF in the characters that it matches).         LF in the characters that it matches).
2124    
2125         Notwithstanding  the above, anomalous effects may still occur when CRLF         Notwithstanding the above, anomalous effects may still occur when  CRLF
2126         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
2127         pattern.         pattern.
2128    
2129           PCRE_NOTBOL           PCRE_NOTBOL
2130    
2131         This option specifies that first character of the subject string is not         This option specifies that first character of the subject string is not
2132         the beginning of a line, so the  circumflex  metacharacter  should  not         the  beginning  of  a  line, so the circumflex metacharacter should not
2133         match  before it. Setting this without PCRE_MULTILINE (at compile time)         match before it. Setting this without PCRE_MULTILINE (at compile  time)
2134         causes circumflex never to match. This option affects only  the  behav-         causes  circumflex  never to match. This option affects only the behav-
2135         iour of the circumflex metacharacter. It does not affect \A.         iour of the circumflex metacharacter. It does not affect \A.
2136    
2137           PCRE_NOTEOL           PCRE_NOTEOL
2138    
2139         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
2140         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
2141         in  multiline mode) a newline immediately before it. Setting this with-         in multiline mode) a newline immediately before it. Setting this  with-
2142         out PCRE_MULTILINE (at compile time) causes dollar never to match. This         out PCRE_MULTILINE (at compile time) causes dollar never to match. This
2143         option  affects only the behaviour of the dollar metacharacter. It does         option affects only the behaviour of the dollar metacharacter. It  does
2144         not affect \Z or \z.         not affect \Z or \z.
2145    
2146           PCRE_NOTEMPTY           PCRE_NOTEMPTY
2147    
2148         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
2149         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
2150         the alternatives match the empty string, the entire  match  fails.  For         the  alternatives  match  the empty string, the entire match fails. For
2151         example, if the pattern         example, if the pattern
2152    
2153           a?b?           a?b?
2154    
2155         is  applied  to  a  string not beginning with "a" or "b", it matches an         is applied to a string not beginning with "a" or  "b",  it  matches  an
2156         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
2157         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-
2158         rences of "a" or "b".         rences of "a" or "b".
2159    
2160           PCRE_NOTEMPTY_ATSTART           PCRE_NOTEMPTY_ATSTART
2161    
2162         This is like PCRE_NOTEMPTY, except that an empty string match  that  is         This  is  like PCRE_NOTEMPTY, except that an empty string match that is
2163         not  at  the  start  of  the  subject  is  permitted. If the pattern is         not at the start of  the  subject  is  permitted.  If  the  pattern  is
2164         anchored, such a match can occur only if the pattern contains \K.         anchored, such a match can occur only if the pattern contains \K.
2165    
2166         Perl    has    no    direct    equivalent    of    PCRE_NOTEMPTY     or         Perl     has    no    direct    equivalent    of    PCRE_NOTEMPTY    or
2167         PCRE_NOTEMPTY_ATSTART,  but  it  does  make a special case of a pattern         PCRE_NOTEMPTY_ATSTART, but it does make a special  case  of  a  pattern
2168         match of the empty string within its split() function, and  when  using         match  of  the empty string within its split() function, and when using
2169         the  /g  modifier.  It  is  possible  to emulate Perl's behaviour after         the /g modifier. It is  possible  to  emulate  Perl's  behaviour  after
2170         matching a null string by first trying the match again at the same off-         matching a null string by first trying the match again at the same off-
2171         set  with  PCRE_NOTEMPTY_ATSTART  and  PCRE_ANCHORED,  and then if that         set with PCRE_NOTEMPTY_ATSTART and  PCRE_ANCHORED,  and  then  if  that
2172         fails, by advancing the starting offset (see below) and trying an ordi-         fails, by advancing the starting offset (see below) and trying an ordi-
2173         nary  match  again. There is some code that demonstrates how to do this         nary match again. There is some code that demonstrates how to  do  this
2174         in the pcredemo sample program. In the most general case, you  have  to         in  the  pcredemo sample program. In the most general case, you have to
2175         check  to  see  if the newline convention recognizes CRLF as a newline,         check to see if the newline convention recognizes CRLF  as  a  newline,
2176         and if so, and the current character is CR followed by LF, advance  the         and  if so, and the current character is CR followed by LF, advance the
2177         starting offset by two characters instead of one.         starting offset by two characters instead of one.
2178    
2179           PCRE_NO_START_OPTIMIZE           PCRE_NO_START_OPTIMIZE
2180    
2181         There  are a number of optimizations that pcre_exec() uses at the start         There are a number of optimizations that pcre_exec() uses at the  start
2182         of a match, in order to speed up the process. For  example,  if  it  is         of  a  match,  in  order to speed up the process. For example, if it is
2183         known that an unanchored match must start with a specific character, it         known that an unanchored match must start with a specific character, it
2184         searches the subject for that character, and fails  immediately  if  it         searches  the  subject  for that character, and fails immediately if it
2185         cannot  find  it,  without actually running the main matching function.         cannot find it, without actually running the  main  matching  function.
2186         This means that a special item such as (*COMMIT) at the start of a pat-         This means that a special item such as (*COMMIT) at the start of a pat-
2187         tern  is  not  considered until after a suitable starting point for the         tern is not considered until after a suitable starting  point  for  the
2188         match has been found. When callouts or (*MARK) items are in use,  these         match  has been found. When callouts or (*MARK) items are in use, these
2189         "start-up" optimizations can cause them to be skipped if the pattern is         "start-up" optimizations can cause them to be skipped if the pattern is
2190         never actually used. The start-up optimizations are in  effect  a  pre-         never  actually  used.  The start-up optimizations are in effect a pre-
2191         scan of the subject that takes place before the pattern is run.         scan of the subject that takes place before the pattern is run.
2192    
2193         The  PCRE_NO_START_OPTIMIZE option disables the start-up optimizations,         The PCRE_NO_START_OPTIMIZE option disables the start-up  optimizations,
2194         possibly causing performance to suffer,  but  ensuring  that  in  cases         possibly  causing  performance  to  suffer,  but ensuring that in cases
2195         where  the  result is "no match", the callouts do occur, and that items         where the result is "no match", the callouts do occur, and  that  items
2196         such as (*COMMIT) and (*MARK) are considered at every possible starting         such as (*COMMIT) and (*MARK) are considered at every possible starting
2197         position  in  the  subject  string. If PCRE_NO_START_OPTIMIZE is set at         position in the subject string. If  PCRE_NO_START_OPTIMIZE  is  set  at
2198         compile time, it cannot be unset at matching time.         compile time, it cannot be unset at matching time.
2199    
2200         Setting PCRE_NO_START_OPTIMIZE can change the  outcome  of  a  matching         Setting  PCRE_NO_START_OPTIMIZE  can  change  the outcome of a matching
2201         operation.  Consider the pattern         operation.  Consider the pattern
2202    
2203           (*COMMIT)ABC           (*COMMIT)ABC
2204    
2205         When  this  is  compiled, PCRE records the fact that a match must start         When this is compiled, PCRE records the fact that a  match  must  start
2206         with the character "A". Suppose the subject  string  is  "DEFABC".  The         with  the  character  "A".  Suppose the subject string is "DEFABC". The
2207         start-up  optimization  scans along the subject, finds "A" and runs the         start-up optimization scans along the subject, finds "A" and  runs  the
2208         first match attempt from there. The (*COMMIT) item means that the  pat-         first  match attempt from there. The (*COMMIT) item means that the pat-
2209         tern  must  match the current starting position, which in this case, it         tern must match the current starting position, which in this  case,  it
2210         does. However, if the same match  is  run  with  PCRE_NO_START_OPTIMIZE         does.  However,  if  the  same match is run with PCRE_NO_START_OPTIMIZE
2211         set,  the  initial  scan  along the subject string does not happen. The         set, the initial scan along the subject string  does  not  happen.  The
2212         first match attempt is run starting  from  "D"  and  when  this  fails,         first  match  attempt  is  run  starting  from "D" and when this fails,
2213         (*COMMIT)  prevents  any  further  matches  being tried, so the overall         (*COMMIT) prevents any further matches  being  tried,  so  the  overall
2214         result is "no match". If the pattern is studied,  more  start-up  opti-         result  is  "no  match". If the pattern is studied, more start-up opti-
2215         mizations  may  be  used. For example, a minimum length for the subject         mizations may be used. For example, a minimum length  for  the  subject
2216         may be recorded. Consider the pattern         may be recorded. Consider the pattern
2217    
2218           (*MARK:A)(X|Y)           (*MARK:A)(X|Y)
2219    
2220         The minimum length for a match is one  character.  If  the  subject  is         The  minimum  length  for  a  match is one character. If the subject is
2221         "ABC",  there  will  be  attempts  to  match "ABC", "BC", "C", and then         "ABC", there will be attempts to  match  "ABC",  "BC",  "C",  and  then
2222         finally an empty string.  If the pattern is studied, the final  attempt         finally  an empty string.  If the pattern is studied, the final attempt
2223         does  not take place, because PCRE knows that the subject is too short,         does not take place, because PCRE knows that the subject is too  short,
2224         and so the (*MARK) is never encountered.  In this  case,  studying  the         and  so  the  (*MARK) is never encountered.  In this case, studying the
2225         pattern  does  not  affect the overall match result, which is still "no         pattern does not affect the overall match result, which  is  still  "no
2226         match", but it does affect the auxiliary information that is returned.         match", but it does affect the auxiliary information that is returned.
2227    
2228           PCRE_NO_UTF8_CHECK           PCRE_NO_UTF8_CHECK
2229    
2230         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
2231         UTF-8  string is automatically checked when pcre_exec() is subsequently         UTF-8 string is automatically checked when pcre_exec() is  subsequently
2232         called.  The value of startoffset is also checked  to  ensure  that  it         called.   The  value  of  startoffset is also checked to ensure that it
2233         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
2234         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
2235         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,
2236         pcre_exec() returns  the  error  PCRE_ERROR_BADUTF8  or,  if  PCRE_PAR-         pcre_exec()  returns  the  error  PCRE_ERROR_BADUTF8  or,  if PCRE_PAR-
2237         TIAL_HARD  is set and the problem is a truncated UTF-8 character at the         TIAL_HARD is set and the problem is a truncated UTF-8 character at  the
2238         end of the subject, PCRE_ERROR_SHORTUTF8.  If  startoffset  contains  a         end  of  the  subject, PCRE_ERROR_SHORTUTF8. In both cases, information
2239         value  that does not point to the start of a UTF-8 character (or to the         about the precise nature of the error may also  be  returned  (see  the
2240         end of the subject), PCRE_ERROR_BADUTF8_OFFSET is returned.         descriptions  of these errors in the section entitled Error return val-
2241           ues from pcre_exec() below).  If startoffset contains a value that does
2242           not  point to the start of a UTF-8 character (or to the end of the sub-
2243           ject), PCRE_ERROR_BADUTF8_OFFSET is returned.
2244    
2245         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
2246         these    checks    for   performance   reasons,   you   can   set   the         these    checks    for   performance   reasons,   you   can   set   the
# Line 2444  MATCHING A PATTERN: THE TRADITIONAL FUNC Line 2470  MATCHING A PATTERN: THE TRADITIONAL FUNC
2470           PCRE_ERROR_BADUTF8        (-10)           PCRE_ERROR_BADUTF8        (-10)
2471    
2472         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
2473         subject.   However,  if  PCRE_PARTIAL_HARD  is set and the problem is a         subject,  and the PCRE_NO_UTF8_CHECK option was not set. If the size of
2474         truncated UTF-8 character at the end of the subject,  PCRE_ERROR_SHORT-         the output vector (ovecsize) is at least 2,  the  byte  offset  to  the
2475         UTF8 is used instead.         start  of  the  the invalid UTF-8 character is placed in the first ele-
2476           ment, and a reason code is placed in the  second  element.  The  reason
2477           codes are listed in the following section.  For backward compatibility,
2478           if PCRE_PARTIAL_HARD is set and the problem is a truncated UTF-8  char-
2479           acter   at   the   end   of   the   subject  (reason  codes  1  to  5),
2480           PCRE_ERROR_SHORTUTF8 is returned instead of PCRE_ERROR_BADUTF8.
2481    
2482           PCRE_ERROR_BADUTF8_OFFSET (-11)           PCRE_ERROR_BADUTF8_OFFSET (-11)
2483    
2484         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  checked  and
2485           found  to be valid (the PCRE_NO_UTF8_CHECK option was not set), but the
2486         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-
2487         ter or the end of the subject.         ter or the end of the subject.
2488    
# Line 2492  MATCHING A PATTERN: THE TRADITIONAL FUNC Line 2524  MATCHING A PATTERN: THE TRADITIONAL FUNC
2524    
2525           PCRE_ERROR_SHORTUTF8      (-25)           PCRE_ERROR_SHORTUTF8      (-25)
2526    
2527         The  subject  string ended with an incomplete (truncated) UTF-8 charac-         This  error  is returned instead of PCRE_ERROR_BADUTF8 when the subject
2528         ter, and the PCRE_PARTIAL_HARD option was  set.  Without  this  option,         string ends with a truncated UTF-8 character and the  PCRE_PARTIAL_HARD
2529         PCRE_ERROR_BADUTF8 is returned in this situation.         option  is  set.   Information  about  the  failure  is returned as for
2530           PCRE_ERROR_BADUTF8. It is in fact sufficient to detect this  case,  but
2531           this  special error code for PCRE_PARTIAL_HARD precedes the implementa-
2532           tion of returned information; it is retained for backwards  compatibil-
2533           ity.
2534    
2535             PCRE_ERROR_RECURSELOOP    (-26)
2536    
2537           This error is returned when pcre_exec() detects a recursion loop within
2538           the pattern. Specifically, it means that either the whole pattern or  a
2539           subpattern  has been called recursively for the second time at the same
2540           position in the subject string. Some simple patterns that might do this
2541           are  detected  and faulted at compile time, but more complicated cases,
2542           in particular mutual recursions between two different subpatterns, can-
2543           not be detected until run time.
2544    
2545         Error numbers -16 to -20 and -22 are not used by pcre_exec().         Error numbers -16 to -20 and -22 are not used by pcre_exec().
2546    
2547       Reason codes for invalid UTF-8 strings
2548    
2549           When pcre_exec() returns either PCRE_ERROR_BADUTF8 or PCRE_ERROR_SHORT-
2550           UTF8, and the size of the output vector (ovecsize) is at least  2,  the
2551           offset  of  the  start  of the invalid UTF-8 character is placed in the
2552           first output vector element (ovector[0]) and a reason code is placed in
2553           the  second  element  (ovector[1]). The reason codes are given names in
2554           the pcre.h header file:
2555    
2556             PCRE_UTF8_ERR1
2557             PCRE_UTF8_ERR2
2558             PCRE_UTF8_ERR3
2559             PCRE_UTF8_ERR4
2560             PCRE_UTF8_ERR5
2561    
2562           The string ends with a truncated UTF-8 character;  the  code  specifies
2563           how  many bytes are missing (1 to 5). Although RFC 3629 restricts UTF-8
2564           characters to be no longer than 4 bytes, the  encoding  scheme  (origi-
2565           nally  defined  by  RFC  2279)  allows  for  up to 6 bytes, and this is
2566           checked first; hence the possibility of 4 or 5 missing bytes.
2567    
2568             PCRE_UTF8_ERR6
2569             PCRE_UTF8_ERR7
2570             PCRE_UTF8_ERR8
2571             PCRE_UTF8_ERR9
2572             PCRE_UTF8_ERR10
2573    
2574           The two most significant bits of the 2nd, 3rd, 4th, 5th, or 6th byte of
2575           the  character  do  not have the binary value 0b10 (that is, either the
2576           most significant bit is 0, or the next bit is 1).
2577    
2578             PCRE_UTF8_ERR11
2579             PCRE_UTF8_ERR12
2580    
2581           A character that is valid by the RFC 2279 rules is either 5 or 6  bytes
2582           long; these code points are excluded by RFC 3629.
2583    
2584             PCRE_UTF8_ERR13
2585    
2586           A  4-byte character has a value greater than 0x10fff; these code points
2587           are excluded by RFC 3629.
2588    
2589             PCRE_UTF8_ERR14
2590    
2591           A 3-byte character has a value in the  range  0xd800  to  0xdfff;  this
2592           range  of code points are reserved by RFC 3629 for use with UTF-16, and
2593           so are excluded from UTF-8.
2594    
2595             PCRE_UTF8_ERR15
2596             PCRE_UTF8_ERR16
2597             PCRE_UTF8_ERR17
2598             PCRE_UTF8_ERR18
2599             PCRE_UTF8_ERR19
2600    
2601           A 2-, 3-, 4-, 5-, or 6-byte character is "overlong", that is, it  codes
2602           for  a  value that can be represented by fewer bytes, which is invalid.
2603           For example, the two bytes 0xc0, 0xae give the value 0x2e,  whose  cor-
2604           rect coding uses just one byte.
2605    
2606             PCRE_UTF8_ERR20
2607    
2608           The two most significant bits of the first byte of a character have the
2609           binary value 0b10 (that is, the most significant bit is 1 and the  sec-
2610           ond  is  0). Such a byte can only validly occur as the second or subse-
2611           quent byte of a multi-byte character.
2612    
2613             PCRE_UTF8_ERR21
2614    
2615           The first byte of a character has the value 0xfe or 0xff. These  values
2616           can never occur in a valid UTF-8 string.
2617    
2618    
2619  EXTRACTING CAPTURED SUBSTRINGS BY NUMBER  EXTRACTING CAPTURED SUBSTRINGS BY NUMBER
2620    
# Line 2673  DUPLICATE SUBPATTERN NAMES Line 2790  DUPLICATE SUBPATTERN NAMES
2790         the  name-to-number  table  for  the  given  name.  The function itself         the  name-to-number  table  for  the  given  name.  The function itself
2791         returns the length of each entry,  or  PCRE_ERROR_NOSUBSTRING  (-7)  if         returns the length of each entry,  or  PCRE_ERROR_NOSUBSTRING  (-7)  if
2792         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-
2793         tion entitled Information about a  pattern.   Given  all  the  relevant         tion entitled Information about a pattern above.  Given all  the  rele-
2794         entries  for the name, you can extract each of their numbers, and hence         vant  entries  for the name, you can extract each of their numbers, and
2795         the captured data, if any.         hence the captured data, if any.
2796    
2797    
2798  FINDING ALL POSSIBLE MATCHES  FINDING ALL POSSIBLE MATCHES
# Line 2874  AUTHOR Line 2991  AUTHOR
2991    
2992  REVISION  REVISION
2993    
2994         Last updated: 21 November 2010         Last updated: 28 July 2011
2995         Copyright (c) 1997-2010 University of Cambridge.         Copyright (c) 1997-2011 University of Cambridge.
2996  ------------------------------------------------------------------------------  ------------------------------------------------------------------------------
2997    
2998    
# Line 2956  THE CALLOUT INTERFACE Line 3073  THE CALLOUT INTERFACE
3073         only argument to the callout function is a pointer  to  a  pcre_callout         only argument to the callout function is a pointer  to  a  pcre_callout
3074         block. This structure contains the following fields:         block. This structure contains the following fields:
3075    
3076           int          version;           int         version;
3077           int          callout_number;           int         callout_number;
3078           int         *offset_vector;           int        *offset_vector;
3079           const char  *subject;           const char *subject;
3080           int          subject_length;           int         subject_length;
3081           int          start_match;           int         start_match;
3082           int          current_position;           int         current_position;
3083           int          capture_top;           int         capture_top;
3084           int          capture_last;           int         capture_last;
3085           void        *callout_data;           void       *callout_data;
3086           int          pattern_position;           int         pattern_position;
3087           int          next_item_length;           int         next_item_length;
3088             const unsigned char *mark;
3089    
3090         The  version  field  is an integer containing the version number of the         The  version  field  is an integer containing the version number of the
3091         block format. The initial version was 0; the current version is 1.  The         block format. The initial version was 0; the current version is 2.  The
3092         version  number  will  change  again in future if additional fields are         version  number  will  change  again in future if additional fields are
3093         added, but the intention is never to remove any of the existing fields.         added, but the intention is never to remove any of the existing fields.
3094    
# Line 3030  THE CALLOUT INTERFACE Line 3148  THE CALLOUT INTERFACE
3148         in  distinguishing between different automatic callouts, which all have         in  distinguishing between different automatic callouts, which all have
3149         the same callout number. However, they are set for all callouts.         the same callout number. However, they are set for all callouts.
3150    
3151           The mark field is present from version 2 of the pcre_callout structure.
3152           In  callouts  from pcre_exec() it contains a pointer to the zero-termi-
3153           nated name of the most recently passed (*MARK) item in  the  match,  or
3154           NULL if there are no (*MARK)s in the current matching path. In callouts
3155           from pcre_dfa_exec() this field always contains NULL.
3156    
3157    
3158  RETURN VALUES  RETURN VALUES
3159    
# Line 3056  AUTHOR Line 3180  AUTHOR
3180    
3181  REVISION  REVISION
3182    
3183         Last updated: 21 November 2010         Last updated: 31 July 2011
3184         Copyright (c) 1997-2010 University of Cambridge.         Copyright (c) 1997-2011 University of Cambridge.
3185  ------------------------------------------------------------------------------  ------------------------------------------------------------------------------
3186    
3187    
# Line 3078  DIFFERENCES BETWEEN PCRE AND PERL Line 3202  DIFFERENCES BETWEEN PCRE AND PERL
3202         of what it does have are given in the section on UTF-8 support  in  the         of what it does have are given in the section on UTF-8 support  in  the
3203         main pcre page.         main pcre page.
3204    
3205         2. PCRE does not allow repeat quantifiers on lookahead assertions. Perl         2. PCRE allows repeat quantifiers only on parenthesized assertions, but
3206         permits them, but they do not mean what you might think.  For  example,         they do not mean what you might think. For example, (?!a){3}  does  not
3207         (?!a){3} does not assert that the next three characters are not "a". It         assert that the next three characters are not "a". It just asserts that
3208         just asserts that the next character is not "a" three times.         the next character is not "a" three times (in principle: PCRE optimizes
3209           this to run the assertion just once). Perl allows repeat quantifiers on
3210           other assertions such as \b, but these do not seem to have any use.
3211    
3212         3. Capturing subpatterns that occur inside  negative  lookahead  asser-         3. Capturing subpatterns that occur inside  negative  lookahead  asser-
3213         tions  are  counted,  but their entries in the offsets vector are never         tions  are  counted,  but their entries in the offsets vector are never
# Line 3096  DIFFERENCES BETWEEN PCRE AND PERL Line 3222  DIFFERENCES BETWEEN PCRE AND PERL
3222         the pattern to represent a binary zero.         the pattern to represent a binary zero.
3223    
3224         5. The following Perl escape sequences are not supported: \l,  \u,  \L,         5. The following Perl escape sequences are not supported: \l,  \u,  \L,
3225         \U, and \N. In fact these are implemented by Perl's general string-han-         \U,  and  \N when followed by a character name or Unicode value. (\N on
3226         dling and are not part of its pattern matching engine. If any of  these         its own, matching a non-newline character, is supported.) In fact these
3227         are encountered by PCRE, an error is generated.         are  implemented  by Perl's general string-handling and are not part of
3228           its pattern matching engine. If any of these are encountered  by  PCRE,
3229           an error is generated.
3230    
3231         6.  The Perl escape sequences \p, \P, and \X are supported only if PCRE         6.  The Perl escape sequences \p, \P, and \X are supported only if PCRE
3232         is built with Unicode character property support. The  properties  that         is built with Unicode character property support. The  properties  that
# Line 3110  DIFFERENCES BETWEEN PCRE AND PERL Line 3238  DIFFERENCES BETWEEN PCRE AND PERL
3238         tion of Unicode characters, there is no need to implement the  somewhat         tion of Unicode characters, there is no need to implement the  somewhat
3239         messy concept of surrogates."         messy concept of surrogates."
3240    
3241         7. PCRE does support the \Q...\E escape for quoting substrings. Charac-         7.  PCRE implements a simpler version of \X than Perl, which changed to
3242         ters in between are treated as literals.  This  is  slightly  different         make \X match what Unicode calls an "extended grapheme  cluster".  This
3243         from  Perl  in  that  $  and  @ are also handled as literals inside the         is  more  complicated  than an extended Unicode sequence, which is what
3244         quotes. In Perl, they cause variable interpolation (but of course  PCRE         PCRE matches.
3245    
3246           8. PCRE does support the \Q...\E escape for quoting substrings. Charac-
3247           ters  in  between  are  treated as literals. This is slightly different
3248           from Perl in that $ and @ are  also  handled  as  literals  inside  the
3249           quotes.  In Perl, they cause variable interpolation (but of course PCRE
3250         does not have variables). Note the following examples:         does not have variables). Note the following examples:
3251    
3252             Pattern            PCRE matches      Perl matches             Pattern            PCRE matches      Perl matches
# Line 3123  DIFFERENCES BETWEEN PCRE AND PERL Line 3256  DIFFERENCES BETWEEN PCRE AND PERL
3256             \Qabc\$xyz\E       abc\$xyz          abc\$xyz             \Qabc\$xyz\E       abc\$xyz          abc\$xyz
3257             \Qabc\E\$\Qxyz\E   abc$xyz           abc$xyz             \Qabc\E\$\Qxyz\E   abc$xyz           abc$xyz
3258    
3259         The  \Q...\E  sequence  is recognized both inside and outside character         The \Q...\E sequence is recognized both inside  and  outside  character
3260         classes.         classes.
3261    
3262         8. Fairly obviously, PCRE does not support the (?{code}) and (??{code})         9. Fairly obviously, PCRE does not support the (?{code}) and (??{code})
3263         constructions.  However,  there is support for recursive patterns. This         constructions. However, there is support for recursive  patterns.  This
3264         is not available in Perl 5.8, but it is in Perl 5.10.  Also,  the  PCRE         is  not  available  in Perl 5.8, but it is in Perl 5.10. Also, the PCRE
3265         "callout"  feature allows an external function to be called during pat-         "callout" feature allows an external function to be called during  pat-
3266         tern matching. See the pcrecallout documentation for details.         tern matching. See the pcrecallout documentation for details.
3267    
3268         9. Subpatterns that are called  recursively  or  as  "subroutines"  are         10.  Subpatterns  that  are  called recursively or as "subroutines" are
3269         always  treated  as  atomic  groups  in  PCRE. This is like Python, but         always treated as atomic groups in  PCRE.  This  is  like  Python,  but
3270         unlike Perl. There is a discussion of an example that explains this  in         unlike  Perl. There is a discussion of an example that explains this in
3271         more  detail  in  the section on recursion differences from Perl in the         more detail in the section on recursion differences from  Perl  in  the
3272         pcrepattern page.         pcrepattern page.
3273    
3274         10. There are some differences that are concerned with the settings  of         11.  There are some differences that are concerned with the settings of
3275         captured  strings  when  part  of  a  pattern is repeated. For example,         captured strings when part of  a  pattern  is  repeated.  For  example,
3276         matching "aba" against the  pattern  /^(a(b)?)+$/  in  Perl  leaves  $2         matching  "aba"  against  the  pattern  /^(a(b)?)+$/  in Perl leaves $2
3277         unset, but in PCRE it is set to "b".         unset, but in PCRE it is set to "b".
3278    
3279         11.  PCRE's handling of duplicate subpattern numbers and duplicate sub-         12. PCRE's handling of duplicate subpattern numbers and duplicate  sub-
3280         pattern names is not as general as Perl's. This is a consequence of the         pattern names is not as general as Perl's. This is a consequence of the
3281         fact the PCRE works internally just with numbers, using an external ta-         fact the PCRE works internally just with numbers, using an external ta-
3282         ble to translate between numbers and names. In  particular,  a  pattern         ble  to  translate  between numbers and names. In particular, a pattern
3283         such  as  (?|(?<a>A)|(?<b)B),  where the two capturing parentheses have         such as (?|(?<a>A)|(?<b)B), where the two  capturing  parentheses  have
3284         the same number but different names, is not supported,  and  causes  an         the  same  number  but different names, is not supported, and causes an
3285         error  at compile time. If it were allowed, it would not be possible to         error at compile time. If it were allowed, it would not be possible  to
3286         distinguish which parentheses matched, because both names map  to  cap-         distinguish  which  parentheses matched, because both names map to cap-
3287         turing subpattern number 1. To avoid this confusing situation, an error         turing subpattern number 1. To avoid this confusing situation, an error
3288         is given at compile time.         is given at compile time.
3289    
3290         12. Perl recognizes comments in some  places  that  PCRE  doesn't,  for         13.  Perl  recognizes  comments  in some places that PCRE does not, for
3291         example, between the ( and ? at the start of a subpattern.         example, between the ( and ? at the start of a subpattern.  If  the  /x
3292           modifier  is set, Perl allows whitespace between ( and ? but PCRE never
3293         13. PCRE provides some extensions to the Perl regular expression facil-         does, even if the PCRE_EXTENDED option is set.
3294         ities.  Perl 5.10 includes new features that are not  in  earlier  ver-  
3295         sions  of  Perl, some of which (such as named parentheses) have been in         14. PCRE provides some extensions to the Perl regular expression facil-
3296           ities.   Perl  5.10  includes new features that are not in earlier ver-
3297           sions of Perl, some of which (such as named parentheses) have  been  in
3298         PCRE for some time. This list is with respect to Perl 5.10:         PCRE for some time. This list is with respect to Perl 5.10:
3299    
3300         (a) Although lookbehind assertions in  PCRE  must  match  fixed  length         (a)  Although  lookbehind  assertions  in  PCRE must match fixed length
3301         strings,  each alternative branch of a lookbehind assertion can match a         strings, each alternative branch of a lookbehind assertion can match  a
3302         different length of string. Perl requires them all  to  have  the  same         different  length  of  string.  Perl requires them all to have the same
3303         length.         length.
3304    
3305         (b)  If PCRE_DOLLAR_ENDONLY is set and PCRE_MULTILINE is not set, the $         (b) If PCRE_DOLLAR_ENDONLY is set and PCRE_MULTILINE is not set, the  $
3306         meta-character matches only at the very end of the string.         meta-character matches only at the very end of the string.
3307    
3308         (c) If PCRE_EXTRA is set, a backslash followed by a letter with no spe-         (c) If PCRE_EXTRA is set, a backslash followed by a letter with no spe-
3309         cial meaning is faulted. Otherwise, like Perl, the backslash is quietly         cial meaning is faulted. Otherwise, like Perl, the backslash is quietly
3310         ignored.  (Perl can be made to issue a warning.)         ignored.  (Perl can be made to issue a warning.)
3311    
3312         (d) If PCRE_UNGREEDY is set, the greediness of the  repetition  quanti-         (d)  If  PCRE_UNGREEDY is set, the greediness of the repetition quanti-
3313         fiers is inverted, that is, by default they are not greedy, but if fol-         fiers is inverted, that is, by default they are not greedy, but if fol-
3314         lowed by a question mark they are.         lowed by a question mark they are.
3315    
# Line 3182  DIFFERENCES BETWEEN PCRE AND PERL Line 3317  DIFFERENCES BETWEEN PCRE AND PERL
3317         tried only at the first matching position in the subject string.         tried only at the first matching position in the subject string.
3318    
3319         (f) The PCRE_NOTBOL, PCRE_NOTEOL, PCRE_NOTEMPTY, PCRE_NOTEMPTY_ATSTART,         (f) The PCRE_NOTBOL, PCRE_NOTEOL, PCRE_NOTEMPTY, PCRE_NOTEMPTY_ATSTART,
3320         and PCRE_NO_AUTO_CAPTURE options for pcre_exec() have no  Perl  equiva-         and  PCRE_NO_AUTO_CAPTURE  options for pcre_exec() have no Perl equiva-
3321         lents.         lents.
3322    
3323         (g)  The  \R escape sequence can be restricted to match only CR, LF, or         (g) The \R escape sequence can be restricted to match only CR,  LF,  or
3324         CRLF by the PCRE_BSR_ANYCRLF option.         CRLF by the PCRE_BSR_ANYCRLF option.
3325    
3326         (h) The callout facility is PCRE-specific.         (h) The callout facility is PCRE-specific.
# Line 3195  DIFFERENCES BETWEEN PCRE AND PERL Line 3330  DIFFERENCES BETWEEN PCRE AND PERL
3330         (j) Patterns compiled by PCRE can be saved and re-used at a later time,         (j) Patterns compiled by PCRE can be saved and re-used at a later time,
3331         even on different hosts that have the other endianness.         even on different hosts that have the other endianness.
3332    
3333         (k)  The  alternative  matching function (pcre_dfa_exec()) matches in a         (k) The alternative matching function (pcre_dfa_exec())  matches  in  a
3334         different way and is not Perl-compatible.         different way and is not Perl-compatible.
3335    
3336         (l) PCRE recognizes some special sequences such as (*CR) at  the  start         (l)  PCRE  recognizes some special sequences such as (*CR) at the start
3337         of a pattern that set overall options that cannot be changed within the         of a pattern that set overall options that cannot be changed within the
3338         pattern.         pattern.
3339    
# Line 3212  AUTHOR Line 3347  AUTHOR
3347    
3348  REVISION  REVISION
3349    
3350         Last updated: 31 October 2010         Last updated: 24 July 2011
3351         Copyright (c) 1997-2010 University of Cambridge.         Copyright (c) 1997-2011 University of Cambridge.
3352  ------------------------------------------------------------------------------  ------------------------------------------------------------------------------
3353    
3354    
# Line 3415  BACKSLASH Line 3550  BACKSLASH
3550           \Qabc\E\$\Qxyz\E   abc$xyz        abc$xyz           \Qabc\E\$\Qxyz\E   abc$xyz        abc$xyz
3551    
3552         The \Q...\E sequence is recognized both inside  and  outside  character         The \Q...\E sequence is recognized both inside  and  outside  character
3553         classes.  An isolated \E that is not preceded by \Q is ignored.         classes.   An  isolated \E that is not preceded by \Q is ignored. If \Q
3554           is not followed by \E later in the pattern, the literal  interpretation
3555           continues  to  the  end  of  the pattern (that is, \E is assumed at the
3556           end). If the isolated \Q is inside a character class,  this  causes  an
3557           error, because the character class is not terminated.
3558    
3559     Non-printing characters     Non-printing characters
3560    
# Line 3808  BACKSLASH Line 3947  BACKSLASH
3947         None  of  them  have  codepoints less than 256, so in non-UTF-8 mode \X         None  of  them  have  codepoints less than 256, so in non-UTF-8 mode \X
3948         matches any one character.         matches any one character.
3949    
3950           Note that recent versions of Perl have changed \X to match what Unicode
3951           calls an "extended grapheme cluster", which has a more complicated def-
3952           inition.
3953    
3954         Matching characters by Unicode property is not fast, because  PCRE  has         Matching characters by Unicode property is not fast, because  PCRE  has
3955         to  search  a  structure  that  contains data for over fifteen thousand         to  search  a  structure  that  contains data for over fifteen thousand
3956         characters. That is why the traditional escape sequences such as \d and         characters. That is why the traditional escape sequences such as \d and
# Line 4431  REPETITION Line 4574  REPETITION
4574           an escape such as \d or \pL that matches a single character           an escape such as \d or \pL that matches a single character
4575           a character class           a character class
4576           a back reference (see next section)           a back reference (see next section)
4577           a parenthesized subpattern (unless it is an assertion)           a parenthesized subpattern (including assertions)
4578           a recursive or "subroutine" call to a subpattern           a recursive or "subroutine" call to a subpattern
4579    
4580         The  general repetition quantifier specifies a minimum and maximum num-         The  general repetition quantifier specifies a minimum and maximum num-
# Line 4807  ASSERTIONS Line 4950  ASSERTIONS
4950         matched  in  the  normal way, except that it does not cause the current         matched  in  the  normal way, except that it does not cause the current
4951         matching position to be changed.         matching position to be changed.
4952    
4953         Assertion subpatterns are not capturing subpatterns,  and  may  not  be         Assertion subpatterns are not capturing subpatterns. If such an  asser-
4954         repeated,  because  it  makes no sense to assert the same thing several         tion  contains  capturing  subpatterns within it, these are counted for
4955         times. If any kind of assertion contains capturing  subpatterns  within         the purposes of numbering the capturing subpatterns in the  whole  pat-
4956         it,  these are counted for the purposes of numbering the capturing sub-         tern.  However,  substring  capturing  is carried out only for positive
4957         patterns in the whole pattern.  However, substring capturing is carried         assertions, because it does not make sense for negative assertions.
4958         out  only  for  positive assertions, because it does not make sense for  
4959         negative assertions.         For compatibility with Perl, assertion  subpatterns  may  be  repeated;
4960           though  it  makes  no sense to assert the same thing several times, the
4961           side effect of capturing parentheses may  occasionally  be  useful.  In
4962           practice, there only three cases:
4963    
4964           (1)  If  the  quantifier  is  {0}, the assertion is never obeyed during
4965           matching.  However, it may  contain  internal  capturing  parenthesized
4966           groups that are called from elsewhere via the subroutine mechanism.
4967    
4968           (2)  If quantifier is {0,n} where n is greater than zero, it is treated
4969           as if it were {0,1}. At run time, the rest  of  the  pattern  match  is
4970           tried with and without the assertion, the order depending on the greed-
4971           iness of the quantifier.
4972    
4973           (3) If the minimum repetition is greater than zero, the  quantifier  is
4974           ignored.   The  assertion  is  obeyed just once when encountered during
4975           matching.
4976    
4977     Lookahead assertions     Lookahead assertions
4978    
# Line 5433  BACKTRACKING CONTROL Line 5592  BACKTRACKING CONTROL
5592    
5593         If any of these verbs are used in an assertion or subroutine subpattern         If any of these verbs are used in an assertion or subroutine subpattern
5594         (including  recursive  subpatterns),  their  effect is confined to that         (including  recursive  subpatterns),  their  effect is confined to that
5595         subpattern; it does not extend to the surrounding  pattern.  Note  that         subpattern; it does not extend to the  surrounding  pattern,  with  one
5596           exception:  a  *MARK  that  is  encountered  in a positive assertion is
5597           passed back (compare capturing parentheses in  assertions).  Note  that
5598         such  subpatterns are processed as anchored at the point where they are         such  subpatterns are processed as anchored at the point where they are
5599         tested.         tested.
5600    
# Line 5519  BACKTRACKING CONTROL Line 5680  BACKTRACKING CONTROL
5680         efficient  way of obtaining this information than putting each alterna-         efficient  way of obtaining this information than putting each alterna-
5681         tive in its own capturing parentheses.         tive in its own capturing parentheses.
5682    
5683           If (*MARK) is encountered in a positive assertion, its name is recorded
5684           and passed back if it is the last-encountered. This does not happen for
5685           negative assetions.
5686    
5687         A name may also be returned after a failed  match  if  the  final  path         A name may also be returned after a failed  match  if  the  final  path
5688         through  the  pattern involves (*MARK). However, unless (*MARK) used in         through  the  pattern involves (*MARK). However, unless (*MARK) used in
5689         conjunction with (*COMMIT), this is unlikely to  happen  for  an  unan-         conjunction with (*COMMIT), this is unlikely to  happen  for  an  unan-
# Line 5691  AUTHOR Line 5856  AUTHOR
5856    
5857  REVISION  REVISION
5858    
5859         Last updated: 21 November 2010         Last updated: 24 July 2011
5860         Copyright (c) 1997-2010 University of Cambridge.         Copyright (c) 1997-2011 University of Cambridge.
5861  ------------------------------------------------------------------------------  ------------------------------------------------------------------------------
5862    
5863    
# Line 7255  PASSING MODIFIERS TO THE REGULAR EXPRESS Line 7420  PASSING MODIFIERS TO THE REGULAR EXPRESS
7420         RE_Options object, set the appropriate options, and pass this object to         RE_Options object, set the appropriate options, and pass this object to
7421         a RE constructor. Example:         a RE constructor. Example:
7422    
7423            RE_options opt;            RE_Options opt;
7424            opt.set_caseless(true);            opt.set_caseless(true);
7425            if (RE("HELLO", opt).PartialMatch("hello world")) ...            if (RE("HELLO", opt).PartialMatch("hello world")) ...
7426    
# Line 7380  AUTHOR Line 7545  AUTHOR
7545  REVISION  REVISION
7546    
7547         Last updated: 17 March 2009         Last updated: 17 March 2009
7548           Minor typo fixed: 25 July 2011
7549  ------------------------------------------------------------------------------  ------------------------------------------------------------------------------
7550    
7551    
# Line 7482  PCRE DISCUSSION OF STACK USAGE Line 7648  PCRE DISCUSSION OF STACK USAGE
7648         in  order to remember the state of the match so that it can back up and         in  order to remember the state of the match so that it can back up and
7649         try a different alternative if the first one fails.  As  matching  pro-         try a different alternative if the first one fails.  As  matching  pro-
7650         ceeds  deeper  and deeper into the tree of possibilities, the recursion         ceeds  deeper  and deeper into the tree of possibilities, the recursion
7651         depth increases.         depth increases. The match() function is also called in  other  circum-
7652           stances,  for example, whenever a parenthesized sub-pattern is entered,
7653           and in certain cases of repetition.
7654    
7655         Not all calls of match() increase the recursion depth; for an item such         Not all calls of match() increase the recursion depth; for an item such
7656         as  a* it may be called several times at the same level, after matching         as  a* it may be called several times at the same level, after matching
# Line 7614  AUTHOR Line 7782  AUTHOR
7782    
7783  REVISION  REVISION
7784    
7785         Last updated: 03 January 2010         Last updated: 22 July 2011
7786         Copyright (c) 1997-2010 University of Cambridge.         Copyright (c) 1997-2011 University of Cambridge.
7787  ------------------------------------------------------------------------------  ------------------------------------------------------------------------------
7788    
7789    

Legend:
Removed from v.589  
changed lines
  Added in v.654

  ViewVC Help
Powered by ViewVC 1.1.5