/[pcre]/code/trunk/doc/html/pcreapi.html
ViewVC logotype

Diff of /code/trunk/doc/html/pcreapi.html

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

revision 91 by nigel, Sat Feb 24 21:41:34 2007 UTC revision 202 by ph10, Fri Aug 3 09:44:26 2007 UTC
# Line 32  man page, in case the conversion went wr Line 32  man page, in case the conversion went wr
32  <li><a name="TOC17" href="#SEC17">DUPLICATE SUBPATTERN NAMES</a>  <li><a name="TOC17" href="#SEC17">DUPLICATE SUBPATTERN NAMES</a>
33  <li><a name="TOC18" href="#SEC18">FINDING ALL POSSIBLE MATCHES</a>  <li><a name="TOC18" href="#SEC18">FINDING ALL POSSIBLE MATCHES</a>
34  <li><a name="TOC19" href="#SEC19">MATCHING A PATTERN: THE ALTERNATIVE FUNCTION</a>  <li><a name="TOC19" href="#SEC19">MATCHING A PATTERN: THE ALTERNATIVE FUNCTION</a>
35    <li><a name="TOC20" href="#SEC20">SEE ALSO</a>
36    <li><a name="TOC21" href="#SEC21">AUTHOR</a>
37    <li><a name="TOC22" href="#SEC22">REVISION</a>
38  </ul>  </ul>
39  <br><a name="SEC1" href="#TOC1">PCRE NATIVE API</a><br>  <br><a name="SEC1" href="#TOC1">PCRE NATIVE API</a><br>
40  <P>  <P>
# Line 140  man page, in case the conversion went wr Line 143  man page, in case the conversion went wr
143  </P>  </P>
144  <br><a name="SEC2" href="#TOC1">PCRE API OVERVIEW</a><br>  <br><a name="SEC2" href="#TOC1">PCRE API OVERVIEW</a><br>
145  <P>  <P>
146  PCRE has its own native API, which is described in this document. There is  PCRE has its own native API, which is described in this document. There are
147  also a set of wrapper functions that correspond to the POSIX regular expression  also some wrapper functions that correspond to the POSIX regular expression
148  API. These are described in the  API. These are described in the
149  <a href="pcreposix.html"><b>pcreposix</b></a>  <a href="pcreposix.html"><b>pcreposix</b></a>
150  documentation. Both of these APIs define a set of C function calls. A C++  documentation. Both of these APIs define a set of C function calls. A C++
# Line 170  documentation describes how to run it. Line 173  documentation describes how to run it.
173  A second matching function, <b>pcre_dfa_exec()</b>, which is not  A second matching function, <b>pcre_dfa_exec()</b>, which is not
174  Perl-compatible, is also provided. This uses a different algorithm for the  Perl-compatible, is also provided. This uses a different algorithm for the
175  matching. The alternative algorithm finds all possible matches (at a given  matching. The alternative algorithm finds all possible matches (at a given
176  point in the subject). However, this algorithm does not return captured  point in the subject), and scans the subject just once. However, this algorithm
177  substrings. A description of the two matching algorithms and their advantages  does not return captured substrings. A description of the two matching
178  and disadvantages is given in the  algorithms and their advantages and disadvantages is given in the
179  <a href="pcrematching.html"><b>pcrematching</b></a>  <a href="pcrematching.html"><b>pcrematching</b></a>
180  documentation.  documentation.
181  </P>  </P>
# Line 243  documentation. Line 246  documentation.
246  </P>  </P>
247  <br><a name="SEC3" href="#TOC1">NEWLINES</a><br>  <br><a name="SEC3" href="#TOC1">NEWLINES</a><br>
248  <P>  <P>
249  PCRE supports three different conventions for indicating line breaks in  PCRE supports five different conventions for indicating line breaks in
250  strings: a single CR character, a single LF character, or the two-character  strings: a single CR (carriage return) character, a single LF (linefeed)
251  sequence CRLF. All three are used as "standard" by different operating systems.  character, the two-character sequence CRLF, any of the three preceding, or any
252  When PCRE is built, a default can be specified. The default default is LF,  Unicode newline sequence. The Unicode newline sequences are the three just
253  which is the Unix standard. When PCRE is run, the default can be overridden,  mentioned, plus the single characters VT (vertical tab, U+000B), FF (formfeed,
254  either when a pattern is compiled, or when it is matched.  U+000C), NEL (next line, U+0085), LS (line separator, U+2028), and PS
255  <br>  (paragraph separator, U+2029).
256  <br>  </P>
257    <P>
258    Each of the first three conventions is used by at least one operating system as
259    its standard newline sequence. When PCRE is built, a default can be specified.
260    The default default is LF, which is the Unix standard. When PCRE is run, the
261    default can be overridden, either when a pattern is compiled, or when it is
262    matched.
263    </P>
264    <P>
265  In the PCRE documentation the word "newline" is used to mean "the character or  In the PCRE documentation the word "newline" is used to mean "the character or
266  pair of characters that indicate a line break".  pair of characters that indicate a line break". The choice of newline
267    convention affects the handling of the dot, circumflex, and dollar
268    metacharacters, the handling of #-comments in /x mode, and, when CRLF is a
269    recognized line ending sequence, the match position advancement for a
270    non-anchored pattern. The choice of newline convention does not affect the
271    interpretation of the \n or \r escape sequences.
272  </P>  </P>
273  <br><a name="SEC4" href="#TOC1">MULTITHREADING</a><br>  <br><a name="SEC4" href="#TOC1">MULTITHREADING</a><br>
274  <P>  <P>
# Line 271  The compiled form of a regular expressio Line 287  The compiled form of a regular expressio
287  time, possibly by a different program, and even on a host other than the one on  time, possibly by a different program, and even on a host other than the one on
288  which it was compiled. Details are given in the  which it was compiled. Details are given in the
289  <a href="pcreprecompile.html"><b>pcreprecompile</b></a>  <a href="pcreprecompile.html"><b>pcreprecompile</b></a>
290  documentation.  documentation. However, compiling a regular expression with one version of PCRE
291    for use with a different version is not guaranteed to work and may cause
292    crashes.
293  </P>  </P>
294  <br><a name="SEC6" href="#TOC1">CHECKING BUILD-TIME OPTIONS</a><br>  <br><a name="SEC6" href="#TOC1">CHECKING BUILD-TIME OPTIONS</a><br>
295  <P>  <P>
# Line 301  properties is available; otherwise it is Line 319  properties is available; otherwise it is
319    PCRE_CONFIG_NEWLINE    PCRE_CONFIG_NEWLINE
320  </pre>  </pre>
321  The output is an integer whose value specifies the default character sequence  The output is an integer whose value specifies the default character sequence
322  that is recognized as meaning "newline". The three values that are supported  that is recognized as meaning "newline". The four values that are supported
323  are: 10 for LF, 13 for CR, and 3338 for CRLF. The default should normally be  are: 10 for LF, 13 for CR, 3338 for CRLF, -2 for ANYCRLF, and -1 for ANY. The
324  the standard sequence for your operating system.  default should normally be the standard sequence for your operating system.
325  <pre>  <pre>
326    PCRE_CONFIG_LINK_SIZE    PCRE_CONFIG_LINK_SIZE
327  </pre>  </pre>
# Line 374  fully relocatable, because it may contai Line 392  fully relocatable, because it may contai
392  argument, which is an address (see below).  argument, which is an address (see below).
393  </P>  </P>
394  <P>  <P>
395  The <i>options</i> argument contains independent bits that affect the  The <i>options</i> argument contains various bit settings that affect the
396  compilation. It should be zero if no options are required. The available  compilation. It should be zero if no options are required. The available
397  options are described below. Some of them, in particular, those that are  options are described below. Some of them, in particular, those that are
398  compatible with Perl, can also be set and unset from within the pattern (see  compatible with Perl, can also be set and unset from within the pattern (see
# Line 467  If this bit is set, a dot metacharater i Line 485  If this bit is set, a dot metacharater i
485  including those that indicate newline. Without it, a dot does not match when  including those that indicate newline. Without it, a dot does not match when
486  the current position is at a newline. This option is equivalent to Perl's /s  the current position is at a newline. This option is equivalent to Perl's /s
487  option, and it can be changed within a pattern by a (?s) option setting. A  option, and it can be changed within a pattern by a (?s) option setting. A
488  negative class such as [^a] always matches newlines, independent of the setting  negative class such as [^a] always matches newline characters, independent of
489  of this option.  the setting of this option.
490  <pre>  <pre>
491    PCRE_DUPNAMES    PCRE_DUPNAMES
492  </pre>  </pre>
# Line 531  occurrences of ^ or $ in a pattern, sett Line 549  occurrences of ^ or $ in a pattern, sett
549    PCRE_NEWLINE_CR    PCRE_NEWLINE_CR
550    PCRE_NEWLINE_LF    PCRE_NEWLINE_LF
551    PCRE_NEWLINE_CRLF    PCRE_NEWLINE_CRLF
552      PCRE_NEWLINE_ANYCRLF
553      PCRE_NEWLINE_ANY
554  </pre>  </pre>
555  These options override the default newline definition that was chosen when PCRE  These options override the default newline definition that was chosen when PCRE
556  was built. Setting the first or the second specifies that a newline is  was built. Setting the first or the second specifies that a newline is
557  indicated by a single character (CR or LF, respectively). Setting both of them  indicated by a single character (CR or LF, respectively). Setting
558  specifies that a newline is indicated by the two-character CRLF sequence. For  PCRE_NEWLINE_CRLF specifies that a newline is indicated by the two-character
559  convenience, PCRE_NEWLINE_CRLF is defined to contain both bits. The only time  CRLF sequence. Setting PCRE_NEWLINE_ANYCRLF specifies that any of the three
560  that a line break is relevant when compiling a pattern is if PCRE_EXTENDED is  preceding sequences should be recognized. Setting PCRE_NEWLINE_ANY specifies
561  set, and an unescaped # outside a character class is encountered. This  that any Unicode newline sequence should be recognized. The Unicode newline
562  indicates a comment that lasts until after the next newline.  sequences are the three just mentioned, plus the single characters VT (vertical
563    tab, U+000B), FF (formfeed, U+000C), NEL (next line, U+0085), LS (line
564    separator, U+2028), and PS (paragraph separator, U+2029). The last two are
565    recognized only in UTF-8 mode.
566    </P>
567    <P>
568    The newline setting in the options word uses three bits that are treated
569    as a number, giving eight possibilities. Currently only six are used (default
570    plus the five values above). This means that if you set more than one newline
571    option, the combination may or may not be sensible. For example,
572    PCRE_NEWLINE_CR with PCRE_NEWLINE_LF is equivalent to PCRE_NEWLINE_CRLF, but
573    other combinations may yield unused numbers and cause an error.
574    </P>
575    <P>
576    The only time that a line break is specially recognized when compiling a
577    pattern is if PCRE_EXTENDED is set, and an unescaped # outside a character
578    class is encountered. This indicates a comment that lasts until after the next
579    line break sequence. In other circumstances, line break sequences are treated
580    as literal data, except that in PCRE_EXTENDED mode, both CR and LF are treated
581    as whitespace characters and are therefore ignored.
582  </P>  </P>
583  <P>  <P>
584  The newline option set at compile time becomes the default that is used for  The newline option that is set at compile time becomes the default that is used
585  <b>pcre_exec()</b> and <b>pcre_dfa_exec()</b>, but it can be overridden.  for <b>pcre_exec()</b> and <b>pcre_dfa_exec()</b>, but it can be overridden.
586  <pre>  <pre>
587    PCRE_NO_AUTO_CAPTURE    PCRE_NO_AUTO_CAPTURE
588  </pre>  </pre>
# Line 587  strings. Line 626  strings.
626  <P>  <P>
627  The following table lists the error codes than may be returned by  The following table lists the error codes than may be returned by
628  <b>pcre_compile2()</b>, along with the error messages that may be returned by  <b>pcre_compile2()</b>, along with the error messages that may be returned by
629  both compiling functions.  both compiling functions. As PCRE has developed, some error codes have fallen
630    out of use. To avoid confusion, they have not been re-used.
631  <pre>  <pre>
632     0  no error     0  no error
633     1  \ at end of pattern     1  \ at end of pattern
# Line 599  both compiling functions. Line 639  both compiling functions.
639     7  invalid escape sequence in character class     7  invalid escape sequence in character class
640     8  range out of order in character class     8  range out of order in character class
641     9  nothing to repeat     9  nothing to repeat
642    10  operand of unlimited repeat could match the empty string    10  [this code is not in use]
643    11  internal error: unexpected repeat    11  internal error: unexpected repeat
644    12  unrecognized character after (?    12  unrecognized character after (?
645    13  POSIX named classes are supported only within a class    13  POSIX named classes are supported only within a class
# Line 608  both compiling functions. Line 648  both compiling functions.
648    16  erroffset passed as NULL    16  erroffset passed as NULL
649    17  unknown option bit(s) set    17  unknown option bit(s) set
650    18  missing ) after comment    18  missing ) after comment
651    19  parentheses nested too deeply    19  [this code is not in use]
652    20  regular expression too large    20  regular expression too large
653    21  failed to get memory    21  failed to get memory
654    22  unmatched parentheses    22  unmatched parentheses
# Line 618  both compiling functions. Line 658  both compiling functions.
658    26  malformed number or name after (?(    26  malformed number or name after (?(
659    27  conditional group contains more than two branches    27  conditional group contains more than two branches
660    28  assertion expected after (?(    28  assertion expected after (?(
661    29  (?R or (?digits must be followed by )    29  (?R or (?[+-]digits must be followed by )
662    30  unknown POSIX class name    30  unknown POSIX class name
663    31  POSIX collating elements are not supported    31  POSIX collating elements are not supported
664    32  this version of PCRE is not compiled with PCRE_UTF8 support    32  this version of PCRE is not compiled with PCRE_UTF8 support
665    33  spare error    33  [this code is not in use]
666    34  character value in \x{...} sequence is too large    34  character value in \x{...} sequence is too large
667    35  invalid condition (?(0)    35  invalid condition (?(0)
668    36  \C not allowed in lookbehind assertion    36  \C not allowed in lookbehind assertion
# Line 631  both compiling functions. Line 671  both compiling functions.
671    39  closing ) for (?C expected    39  closing ) for (?C expected
672    40  recursive call could loop indefinitely    40  recursive call could loop indefinitely
673    41  unrecognized character after (?P    41  unrecognized character after (?P
674    42  syntax error after (?P    42  syntax error in subpattern name (missing terminator)
675    43  two named subpatterns have the same name    43  two named subpatterns have the same name
676    44  invalid UTF-8 string    44  invalid UTF-8 string
677    45  support for \P, \p, and \X has not been compiled    45  support for \P, \p, and \X has not been compiled
# Line 639  both compiling functions. Line 679  both compiling functions.
679    47  unknown property name after \P or \p    47  unknown property name after \P or \p
680    48  subpattern name is too long (maximum 32 characters)    48  subpattern name is too long (maximum 32 characters)
681    49  too many named subpatterns (maximum 10,000)    49  too many named subpatterns (maximum 10,000)
682    50  repeated subpattern is too long    50  [this code is not in use]
683    51  octal value is greater than \377 (not in UTF-8 mode)    51  octal value is greater than \377 (not in UTF-8 mode)
684      52  internal error: overran compiling workspace
685      53  internal error: previously-checked referenced subpattern not found
686      54  DEFINE group contains more than one branch
687      55  repeating a DEFINE group is not allowed
688      56  inconsistent NEWLINE options"
689      57  \g is not followed by a braced name or an optionally braced
690            non-zero number
691      58  (?+ or (?- or (?(+ or (?(- must be followed by a non-zero number
692  </PRE>  </PRE>
693  </P>  </P>
694  <br><a name="SEC9" href="#TOC1">STUDYING A PATTERN</a><br>  <br><a name="SEC9" href="#TOC1">STUDYING A PATTERN</a><br>
# Line 698  bytes is created. Line 746  bytes is created.
746  <a name="localesupport"></a></P>  <a name="localesupport"></a></P>
747  <br><a name="SEC10" href="#TOC1">LOCALE SUPPORT</a><br>  <br><a name="SEC10" href="#TOC1">LOCALE SUPPORT</a><br>
748  <P>  <P>
749  PCRE handles caseless matching, and determines whether characters are letters  PCRE handles caseless matching, and determines whether characters are letters,
750  digits, or whatever, by reference to a set of tables, indexed by character  digits, or whatever, by reference to a set of tables, indexed by character
751  value. When running in UTF-8 mode, this applies only to characters with codes  value. When running in UTF-8 mode, this applies only to characters with codes
752  less than 128. Higher-valued codes never match escapes such as \w or \d, but  less than 128. Higher-valued codes never match escapes such as \w or \d, but
753  can be tested with \p if PCRE is built with Unicode character property  can be tested with \p if PCRE is built with Unicode character property
754  support. The use of locales with Unicode is discouraged.  support. The use of locales with Unicode is discouraged. If you are handling
755  </P>  characters with codes greater than 128, you should either use UTF-8 and
756  <P>  Unicode, or use locales, but not try to mix the two.
757  An internal set of tables is created in the default C locale when PCRE is  </P>
758  built. This is used when the final argument of <b>pcre_compile()</b> is NULL,  <P>
759  and is sufficient for many applications. An alternative set of tables can,  PCRE contains an internal set of tables that are used when the final argument
760  however, be supplied. These may be created in a different locale from the  of <b>pcre_compile()</b> is NULL. These are sufficient for many applications.
761  default. As more and more applications change to using Unicode, the need for  Normally, the internal tables recognize only ASCII characters. However, when
762  this locale support is expected to die away.  PCRE is built, it is possible to cause the internal tables to be rebuilt in the
763    default "C" locale of the local system, which may cause them to be different.
764    </P>
765    <P>
766    The internal tables can always be overridden by tables supplied by the
767    application that calls PCRE. These may be created in a different locale from
768    the default. As more and more applications change to using Unicode, the need
769    for this locale support is expected to die away.
770  </P>  </P>
771  <P>  <P>
772  External tables are built by calling the <b>pcre_maketables()</b> function,  External tables are built by calling the <b>pcre_maketables()</b> function,
# Line 725  the following code could be used: Line 780  the following code could be used:
780    tables = pcre_maketables();    tables = pcre_maketables();
781    re = pcre_compile(..., tables);    re = pcre_compile(..., tables);
782  </pre>  </pre>
783    The locale name "fr_FR" is used on Linux and other Unix-like systems; if you
784    are using Windows, the name for the French locale is "french".
785    </P>
786    <P>
787  When <b>pcre_maketables()</b> runs, the tables are built in memory that is  When <b>pcre_maketables()</b> runs, the tables are built in memory that is
788  obtained via <b>pcre_malloc</b>. It is the caller's responsibility to ensure  obtained via <b>pcre_malloc</b>. It is the caller's responsibility to ensure
789  that the memory containing the tables remains available for as long as it is  that the memory containing the tables remains available for as long as it is
# Line 810  still recognized for backwards compatibi Line 869  still recognized for backwards compatibi
869  </P>  </P>
870  <P>  <P>
871  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
872  (cat|cow|coyote). Otherwise, if either  (cat|cow|coyote), its value is returned. Otherwise, if either
873  <br>  <br>
874  <br>  <br>
875  (a) the pattern was compiled with the PCRE_MULTILINE option, and every branch  (a) the pattern was compiled with the PCRE_MULTILINE option, and every branch
# Line 832  table indicating a fixed set of bytes fo Line 891  table indicating a fixed set of bytes fo
891  string, a pointer to the table is returned. Otherwise NULL is returned. The  string, a pointer to the table is returned. Otherwise NULL is returned. The
892  fourth argument should point to an <b>unsigned char *</b> variable.  fourth argument should point to an <b>unsigned char *</b> variable.
893  <pre>  <pre>
894      PCRE_INFO_JCHANGED
895    </pre>
896    Return 1 if the (?J) option setting is used in the pattern, otherwise 0. The
897    fourth argument should point to an <b>int</b> variable. The (?J) internal option
898    setting changes the local PCRE_DUPNAMES option.
899    <pre>
900    PCRE_INFO_LASTLITERAL    PCRE_INFO_LASTLITERAL
901  </pre>  </pre>
902  Return the value of the rightmost literal byte that must exist in any matched  Return the value of the rightmost literal byte that must exist in any matched
# Line 868  alphabetical order. When PCRE_DUPNAMES i Line 933  alphabetical order. When PCRE_DUPNAMES i
933  their parentheses numbers. For example, consider the following pattern (assume  their parentheses numbers. For example, consider the following pattern (assume
934  PCRE_EXTENDED is set, so white space - including newlines - is ignored):  PCRE_EXTENDED is set, so white space - including newlines - is ignored):
935  <pre>  <pre>
936    (?P&#60;date&#62; (?P&#60;year&#62;(\d\d)?\d\d) - (?P&#60;month&#62;\d\d) - (?P&#60;day&#62;\d\d) )    (?&#60;date&#62; (?&#60;year&#62;(\d\d)?\d\d) - (?&#60;month&#62;\d\d) - (?&#60;day&#62;\d\d) )
937  </pre>  </pre>
938  There are four named subpatterns, so the table has four entries, and each entry  There are four named subpatterns, so the table has four entries, and each entry
939  in the table is eight bytes long. The table is as follows, with non-printing  in the table is eight bytes long. The table is as follows, with non-printing
# Line 883  When writing code to extract data from n Line 948  When writing code to extract data from n
948  name-to-number map, remember that the length of the entries is likely to be  name-to-number map, remember that the length of the entries is likely to be
949  different for each compiled pattern.  different for each compiled pattern.
950  <pre>  <pre>
951      PCRE_INFO_OKPARTIAL
952    </pre>
953    Return 1 if the pattern can be used for partial matching, otherwise 0. The
954    fourth argument should point to an <b>int</b> variable. The
955    <a href="pcrepartial.html"><b>pcrepartial</b></a>
956    documentation lists the restrictions that apply to patterns when partial
957    matching is used.
958    <pre>
959    PCRE_INFO_OPTIONS    PCRE_INFO_OPTIONS
960  </pre>  </pre>
961  Return a copy of the options with which the pattern was compiled. The fourth  Return a copy of the options with which the pattern was compiled. The fourth
962  argument should point to an <b>unsigned long int</b> variable. These option bits  argument should point to an <b>unsigned long int</b> variable. These option bits
963  are those specified in the call to <b>pcre_compile()</b>, modified by any  are those specified in the call to <b>pcre_compile()</b>, modified by any
964  top-level option settings within the pattern itself.  top-level option settings at the start of the pattern itself. In other words,
965    they are the options that will be in force when matching starts. For example,
966    if the pattern /(?im)abc(?-i)d/ is compiled with the PCRE_EXTENDED option, the
967    result is PCRE_CASELESS, PCRE_MULTILINE, and PCRE_EXTENDED.
968  </P>  </P>
969  <P>  <P>
970  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
# Line 1116  matching time. Line 1192  matching time.
1192    PCRE_NEWLINE_CR    PCRE_NEWLINE_CR
1193    PCRE_NEWLINE_LF    PCRE_NEWLINE_LF
1194    PCRE_NEWLINE_CRLF    PCRE_NEWLINE_CRLF
1195      PCRE_NEWLINE_ANYCRLF
1196      PCRE_NEWLINE_ANY
1197  </pre>  </pre>
1198  These options override the newline definition that was chosen or defaulted when  These options override the newline definition that was chosen or defaulted when
1199  the pattern was compiled. For details, see the description <b>pcre_compile()</b>  the pattern was compiled. For details, see the description of
1200  above. During matching, the newline choice affects the behaviour of the dot,  <b>pcre_compile()</b> above. During matching, the newline choice affects the
1201  circumflex, and dollar metacharacters.  behaviour of the dot, circumflex, and dollar metacharacters. It may also alter
1202    the way the match position is advanced after a match failure for an unanchored
1203    pattern. When PCRE_NEWLINE_CRLF, PCRE_NEWLINE_ANYCRLF, or PCRE_NEWLINE_ANY is
1204    set, and a match attempt fails when the current position is at a CRLF sequence,
1205    the match position is advanced by two characters instead of one, in other
1206    words, to after the CRLF.
1207  <pre>  <pre>
1208    PCRE_NOTBOL    PCRE_NOTBOL
1209  </pre>  </pre>
# Line 1334  compiled in an environment of one endian Line 1417  compiled in an environment of one endian
1417  other endianness. This is the error that PCRE gives when the magic number is  other endianness. This is the error that PCRE gives when the magic number is
1418  not present.  not present.
1419  <pre>  <pre>
1420    PCRE_ERROR_UNKNOWN_NODE   (-5)    PCRE_ERROR_UNKNOWN_OPCODE (-5)
1421  </pre>  </pre>
1422  While running the pattern match, an unknown item was encountered in the  While running the pattern match, an unknown item was encountered in the
1423  compiled pattern. This error could be caused by a bug in PCRE or by overwriting  compiled pattern. This error could be caused by a bug in PCRE or by overwriting
# Line 1360  The backtracking limit, as specified by Line 1443  The backtracking limit, as specified by
1443  <b>pcre_extra</b> structure (or defaulted) was reached. See the description  <b>pcre_extra</b> structure (or defaulted) was reached. See the description
1444  above.  above.
1445  <pre>  <pre>
   PCRE_ERROR_RECURSIONLIMIT (-21)  
 </pre>  
 The internal recursion limit, as specified by the <i>match_limit_recursion</i>  
 field in a <b>pcre_extra</b> structure (or defaulted) was reached. See the  
 description above.  
 <pre>  
1446    PCRE_ERROR_CALLOUT        (-9)    PCRE_ERROR_CALLOUT        (-9)
1447  </pre>  </pre>
1448  This error is never generated by <b>pcre_exec()</b> itself. It is provided for  This error is never generated by <b>pcre_exec()</b> itself. It is provided for
# Line 1403  in PCRE or by overwriting of the compile Line 1480  in PCRE or by overwriting of the compile
1480    PCRE_ERROR_BADCOUNT       (-15)    PCRE_ERROR_BADCOUNT       (-15)
1481  </pre>  </pre>
1482  This error is given if the value of the <i>ovecsize</i> argument is negative.  This error is given if the value of the <i>ovecsize</i> argument is negative.
1483    <pre>
1484      PCRE_ERROR_RECURSIONLIMIT (-21)
1485    </pre>
1486    The internal recursion limit, as specified by the <i>match_limit_recursion</i>
1487    field in a <b>pcre_extra</b> structure (or defaulted) was reached. See the
1488    description above.
1489    <pre>
1490      PCRE_ERROR_BADNEWLINE     (-23)
1491    </pre>
1492    An invalid combination of PCRE_NEWLINE_<i>xxx</i> options was given.
1493    </P>
1494    <P>
1495    Error numbers -16 to -20 and -22 are not used by <b>pcre_exec()</b>.
1496  </P>  </P>
1497  <br><a name="SEC15" href="#TOC1">EXTRACTING CAPTURED SUBSTRINGS BY NUMBER</a><br>  <br><a name="SEC15" href="#TOC1">EXTRACTING CAPTURED SUBSTRINGS BY NUMBER</a><br>
1498  <P>  <P>
# Line 1457  the string is placed in <i>buffer</i>, w Line 1547  the string is placed in <i>buffer</i>, w
1547  <i>buffersize</i>, while for <b>pcre_get_substring()</b> a new block of memory is  <i>buffersize</i>, while for <b>pcre_get_substring()</b> a new block of memory is
1548  obtained via <b>pcre_malloc</b>, and its address is returned via  obtained via <b>pcre_malloc</b>, and its address is returned via
1549  <i>stringptr</i>. The yield of the function is the length of the string, not  <i>stringptr</i>. The yield of the function is the length of the string, not
1550  including the terminating zero, or one of  including the terminating zero, or one of these error codes:
1551  <pre>  <pre>
1552    PCRE_ERROR_NOMEMORY       (-6)    PCRE_ERROR_NOMEMORY       (-6)
1553  </pre>  </pre>
# Line 1474  and builds a list of pointers to them. A Line 1564  and builds a list of pointers to them. A
1564  memory that is obtained via <b>pcre_malloc</b>. The address of the memory block  memory that is obtained via <b>pcre_malloc</b>. The address of the memory block
1565  is returned via <i>listptr</i>, which is also the start of the list of string  is returned via <i>listptr</i>, which is also the start of the list of string
1566  pointers. The end of the list is marked by a NULL pointer. The yield of the  pointers. The end of the list is marked by a NULL pointer. The yield of the
1567  function is zero if all went well, or  function is zero if all went well, or the error code
1568  <pre>  <pre>
1569    PCRE_ERROR_NOMEMORY       (-6)    PCRE_ERROR_NOMEMORY       (-6)
1570  </pre>  </pre>
# Line 1520  provided. Line 1610  provided.
1610  To extract a substring by name, you first have to find associated number.  To extract a substring by name, you first have to find associated number.
1611  For example, for this pattern  For example, for this pattern
1612  <pre>  <pre>
1613    (a+)b(?P&#60;xxx&#62;\d+)...    (a+)b(?&#60;xxx&#62;\d+)...
1614  </pre>  </pre>
1615  the number of the subpattern called "xxx" is 2. If the name is known to be  the number of the subpattern called "xxx" is 2. If the name is known to be
1616  unique (PCRE_DUPNAMES was not set), you can find the number from the name by  unique (PCRE_DUPNAMES was not set), you can find the number from the name by
# Line 1548  translation table. Line 1638  translation table.
1638  </P>  </P>
1639  <P>  <P>
1640  These functions call <b>pcre_get_stringnumber()</b>, and if it succeeds, they  These functions call <b>pcre_get_stringnumber()</b>, and if it succeeds, they
1641  then call <i>pcre_copy_substring()</i> or <i>pcre_get_substring()</i>, as  then call <b>pcre_copy_substring()</b> or <b>pcre_get_substring()</b>, as
1642  appropriate.  appropriate. <b>NOTE:</b> If PCRE_DUPNAMES is set and there are duplicate names,
1643    the behaviour may not be what you want (see the next section).
1644  </P>  </P>
1645  <br><a name="SEC17" href="#TOC1">DUPLICATE SUBPATTERN NAMES</a><br>  <br><a name="SEC17" href="#TOC1">DUPLICATE SUBPATTERN NAMES</a><br>
1646  <P>  <P>
# Line 1575  argument is the compiled pattern, and th Line 1666  argument is the compiled pattern, and th
1666  fourth are pointers to variables which are updated by the function. After it  fourth are pointers to variables which are updated by the function. After it
1667  has run, they point to the first and last entries in the name-to-number table  has run, they point to the first and last entries in the name-to-number table
1668  for the given name. The function itself returns the length of each entry, or  for the given name. The function itself returns the length of each entry, or
1669  PCRE_ERROR_NOSUBSTRING if there are none. The format of the table is described  PCRE_ERROR_NOSUBSTRING (-7) if there are none. The format of the table is
1670  above in the section entitled <i>Information about a pattern</i>. Given all the  described above in the section entitled <i>Information about a pattern</i>.
1671  relevant entries for the name, you can extract each of their numbers, and hence  Given all the relevant entries for the name, you can extract each of their
1672  the captured data, if any.  numbers, and hence the captured data, if any.
1673  </P>  </P>
1674  <br><a name="SEC18" href="#TOC1">FINDING ALL POSSIBLE MATCHES</a><br>  <br><a name="SEC18" href="#TOC1">FINDING ALL POSSIBLE MATCHES</a><br>
1675  <P>  <P>
# Line 1608  will yield PCRE_ERROR_NOMATCH. Line 1699  will yield PCRE_ERROR_NOMATCH.
1699  </P>  </P>
1700  <P>  <P>
1701  The function <b>pcre_dfa_exec()</b> is called to match a subject string against  The function <b>pcre_dfa_exec()</b> is called to match a subject string against
1702  a compiled pattern, using a "DFA" matching algorithm. This has different  a compiled pattern, using a matching algorithm that scans the subject string
1703  characteristics to the normal algorithm, and is not compatible with Perl. Some  just once, and does not backtrack. This has different characteristics to the
1704  of the features of PCRE patterns are not supported. Nevertheless, there are  normal algorithm, and is not compatible with Perl. Some of the features of PCRE
1705  times when this kind of matching can be useful. For a discussion of the two  patterns are not supported. Nevertheless, there are times when this kind of
1706  matching algorithms, see the  matching can be useful. For a discussion of the two matching algorithms, see
1707    the
1708  <a href="pcrematching.html"><b>pcrematching</b></a>  <a href="pcrematching.html"><b>pcrematching</b></a>
1709  documentation.  documentation.
1710  </P>  </P>
# Line 1671  matching string. Line 1763  matching string.
1763    PCRE_DFA_SHORTEST    PCRE_DFA_SHORTEST
1764  </pre>  </pre>
1765  Setting the PCRE_DFA_SHORTEST option causes the matching algorithm to stop as  Setting the PCRE_DFA_SHORTEST option causes the matching algorithm to stop as
1766  soon as it has found one match. Because of the way the DFA algorithm works,  soon as it has found one match. Because of the way the alternative algorithm
1767  this is necessarily the shortest possible match at the first possible matching  works, this is necessarily the shortest possible match at the first possible
1768  point in the subject string.  matching point in the subject string.
1769  <pre>  <pre>
1770    PCRE_DFA_RESTART    PCRE_DFA_RESTART
1771  </pre>  </pre>
# Line 1711  the three matched strings are Line 1803  the three matched strings are
1803  On success, the yield of the function is a number greater than zero, which is  On success, the yield of the function is a number greater than zero, which is
1804  the number of matched substrings. The substrings themselves are returned in  the number of matched substrings. The substrings themselves are returned in
1805  <i>ovector</i>. Each string uses two elements; the first is the offset to the  <i>ovector</i>. Each string uses two elements; the first is the offset to the
1806  start, and the second is the offset to the end. All the strings have the same  start, and the second is the offset to the end. In fact, all the strings have
1807  start offset. (Space could have been saved by giving this only once, but it was  the same start offset. (Space could have been saved by giving this only once,
1808  decided to retain some compatibility with the way <b>pcre_exec()</b> returns  but it was decided to retain some compatibility with the way <b>pcre_exec()</b>
1809  data, even though the meaning of the strings is different.)  returns data, even though the meaning of the strings is different.)
1810  </P>  </P>
1811  <P>  <P>
1812  The strings are returned in reverse order of length; that is, the longest  The strings are returned in reverse order of length; that is, the longest
# Line 1740  that it does not support, for instance, Line 1832  that it does not support, for instance,
1832  <pre>  <pre>
1833    PCRE_ERROR_DFA_UCOND      (-17)    PCRE_ERROR_DFA_UCOND      (-17)
1834  </pre>  </pre>
1835  This return is given if <b>pcre_dfa_exec()</b> encounters a condition item in a  This return is given if <b>pcre_dfa_exec()</b> encounters a condition item that
1836  pattern that uses a back reference for the condition. This is not supported.  uses a back reference for the condition, or a test for recursion in a specific
1837    group. These are not supported.
1838  <pre>  <pre>
1839    PCRE_ERROR_DFA_UMLIMIT    (-18)    PCRE_ERROR_DFA_UMLIMIT    (-18)
1840  </pre>  </pre>
# Line 1761  recursively, using private vectors for < Line 1854  recursively, using private vectors for <
1854  error is given if the output vector is not large enough. This should be  error is given if the output vector is not large enough. This should be
1855  extremely rare, as a vector of size 1000 is used.  extremely rare, as a vector of size 1000 is used.
1856  </P>  </P>
1857    <br><a name="SEC20" href="#TOC1">SEE ALSO</a><br>
1858    <P>
1859    <b>pcrebuild</b>(3), <b>pcrecallout</b>(3), <b>pcrecpp(3)</b>(3),
1860    <b>pcrematching</b>(3), <b>pcrepartial</b>(3), <b>pcreposix</b>(3),
1861    <b>pcreprecompile</b>(3), <b>pcresample</b>(3), <b>pcrestack</b>(3).
1862    </P>
1863    <br><a name="SEC21" href="#TOC1">AUTHOR</a><br>
1864    <P>
1865    Philip Hazel
1866    <br>
1867    University Computing Service
1868    <br>
1869    Cambridge CB2 3QH, England.
1870    <br>
1871    </P>
1872    <br><a name="SEC22" href="#TOC1">REVISION</a><br>
1873  <P>  <P>
1874  Last updated: 08 June 2006  Last updated: 30 July 2007
1875    <br>
1876    Copyright &copy; 1997-2007 University of Cambridge.
1877  <br>  <br>
 Copyright &copy; 1997-2006 University of Cambridge.  
1878  <p>  <p>
1879  Return to the <a href="index.html">PCRE index page</a>.  Return to the <a href="index.html">PCRE index page</a>.
1880  </p>  </p>

Legend:
Removed from v.91  
changed lines
  Added in v.202

  ViewVC Help
Powered by ViewVC 1.1.5