/[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 99 by ph10, Tue Mar 6 12:27:42 2007 UTC revision 345 by ph10, Mon Apr 28 15:10:02 2008 UTC
# Line 7  Line 7 
7  <p>  <p>
8  Return to the <a href="index.html">PCRE index page</a>.  Return to the <a href="index.html">PCRE index page</a>.
9  </p>  </p>
10  <p>  <p>
11  This page is part of the PCRE HTML documentation. It was generated automatically  This page is part of the PCRE HTML documentation. It was generated automatically
12  from the original man page. If there is any nonsense in it, please consult the  from the original man page. If there is any nonsense in it, please consult the
13  man page, in case the conversion went wrong.  man page, in case the conversion went wrong.
14  <br>  <br>
15  <ul>  <ul>
16  <li><a name="TOC1" href="#SEC1">PCRE NATIVE API</a>  <li><a name="TOC1" href="#SEC1">PCRE NATIVE API</a>
17  <li><a name="TOC2" href="#SEC2">PCRE API OVERVIEW</a>  <li><a name="TOC2" href="#SEC2">PCRE API OVERVIEW</a>
# Line 167  in a Perl-compatible manner. A sample pr Line 167  in a Perl-compatible manner. A sample pr
167  way of using them is provided in the file called <i>pcredemo.c</i> in the source  way of using them is provided in the file called <i>pcredemo.c</i> in the source
168  distribution. The  distribution. The
169  <a href="pcresample.html"><b>pcresample</b></a>  <a href="pcresample.html"><b>pcresample</b></a>
170  documentation describes how to run it.  documentation describes how to compile and run it.
171  </P>  </P>
172  <P>  <P>
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
# Line 243  by the caller to a "callout" function, w Line 243  by the caller to a "callout" function, w
243  points during a matching operation. Details are given in the  points during a matching operation. Details are given in the
244  <a href="pcrecallout.html"><b>pcrecallout</b></a>  <a href="pcrecallout.html"><b>pcrecallout</b></a>
245  documentation.  documentation.
246  </P>  <a name="newlines"></a></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 four different conventions for indicating line breaks in  PCRE supports five different conventions for indicating line breaks in
250  strings: a single CR (carriage return) character, a single LF (linefeed)  strings: a single CR (carriage return) character, a single LF (linefeed)
251  character, the two-character sequence CRLF, or any Unicode newline sequence.  character, the two-character sequence CRLF, any of the three preceding, or any
252  The Unicode newline sequences are the three just mentioned, plus the single  Unicode newline sequence. The Unicode newline sequences are the three just
253  characters VT (vertical tab, U+000B), FF (formfeed, U+000C), NEL (next line,  mentioned, plus the single characters VT (vertical tab, U+000B), FF (formfeed,
254  U+0085), LS (line separator, U+2028), and PS (paragraph separator, U+2029).  U+000C), NEL (next line, U+0085), LS (line separator, U+2028), and PS
255    (paragraph separator, U+2029).
256  </P>  </P>
257  <P>  <P>
258  Each of the first three conventions is used by at least one operating system as  Each of the first three conventions is used by at least one operating system as
# Line 261  default can be overridden, either when a Line 262  default can be overridden, either when a
262  matched.  matched.
263  </P>  </P>
264  <P>  <P>
265    At compile time, the newline convention can be specified by the <i>options</i>
266    argument of <b>pcre_compile()</b>, or it can be specified by special text at the
267    start of the pattern itself; this overrides any other settings. See the
268    <a href="pcrepattern.html"><b>pcrepattern</b></a>
269    page for details of the special character sequences.
270    </P>
271    <P>
272  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
273  pair of characters that indicate a line break". The choice of newline  pair of characters that indicate a line break". The choice of newline
274  convention affects the handling of the dot, circumflex, and dollar  convention affects the handling of the dot, circumflex, and dollar
275  metacharacters, the handling of #-comments in /x mode, and, when CRLF is a  metacharacters, the handling of #-comments in /x mode, and, when CRLF is a
276  recognized line ending sequence, the match position advancement for a  recognized line ending sequence, the match position advancement for a
277  non-anchored pattern. The choice of newline convention does not affect the  non-anchored pattern. There is more detail about this in the
278  interpretation of the \n or \r escape sequences.  <a href="#execoptions">section on <b>pcre_exec()</b> options</a>
279    below.
280    </P>
281    <P>
282    The choice of newline convention does not affect the interpretation of
283    the \n or \r escape sequences, nor does it affect what \R matches, which is
284    controlled in a similar way, but by separate options.
285  </P>  </P>
286  <br><a name="SEC4" href="#TOC1">MULTITHREADING</a><br>  <br><a name="SEC4" href="#TOC1">MULTITHREADING</a><br>
287  <P>  <P>
# Line 286  The compiled form of a regular expressio Line 300  The compiled form of a regular expressio
300  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
301  which it was compiled. Details are given in the  which it was compiled. Details are given in the
302  <a href="pcreprecompile.html"><b>pcreprecompile</b></a>  <a href="pcreprecompile.html"><b>pcreprecompile</b></a>
303  documentation.  documentation. However, compiling a regular expression with one version of PCRE
304    for use with a different version is not guaranteed to work and may cause
305    crashes.
306  </P>  </P>
307  <br><a name="SEC6" href="#TOC1">CHECKING BUILD-TIME OPTIONS</a><br>  <br><a name="SEC6" href="#TOC1">CHECKING BUILD-TIME OPTIONS</a><br>
308  <P>  <P>
# Line 317  properties is available; otherwise it is Line 333  properties is available; otherwise it is
333  </pre>  </pre>
334  The output is an integer whose value specifies the default character sequence  The output is an integer whose value specifies the default character sequence
335  that is recognized as meaning "newline". The four values that are supported  that is recognized as meaning "newline". The four values that are supported
336  are: 10 for LF, 13 for CR, 3338 for CRLF, and -1 for ANY. The default should  are: 10 for LF, 13 for CR, 3338 for CRLF, -2 for ANYCRLF, and -1 for ANY. The
337  normally be the standard sequence for your operating system.  default should normally be the standard sequence for your operating system.
338    <pre>
339      PCRE_CONFIG_BSR
340    </pre>
341    The output is an integer whose value indicates what character sequences the \R
342    escape sequence matches by default. A value of 0 means that \R matches any
343    Unicode line ending sequence; a value of 1 means that \R matches only CR, LF,
344    or CRLF. The default can be overridden when a pattern is compiled or matched.
345  <pre>  <pre>
346    PCRE_CONFIG_LINK_SIZE    PCRE_CONFIG_LINK_SIZE
347  </pre>  </pre>
# Line 455  facility, see the Line 478  facility, see the
478  <a href="pcrecallout.html"><b>pcrecallout</b></a>  <a href="pcrecallout.html"><b>pcrecallout</b></a>
479  documentation.  documentation.
480  <pre>  <pre>
481      PCRE_BSR_ANYCRLF
482      PCRE_BSR_UNICODE
483    </pre>
484    These options (which are mutually exclusive) control what the \R escape
485    sequence matches. The choice is either to match only CR, LF, or CRLF, or to
486    match any Unicode newline sequence. The default is specified when PCRE is
487    built. It can be overridden from within the pattern, or by setting an option
488    when a compiled pattern is matched.
489    <pre>
490    PCRE_CASELESS    PCRE_CASELESS
491  </pre>  </pre>
492  If this bit is set, letters in the pattern match both upper and lower case  If this bit is set, letters in the pattern match both upper and lower case
# Line 526  If this option is set, an unanchored pat Line 558  If this option is set, an unanchored pat
558  the first newline in the subject string, though the matched text may continue  the first newline in the subject string, though the matched text may continue
559  over the newline.  over the newline.
560  <pre>  <pre>
561      PCRE_JAVASCRIPT_COMPAT
562    </pre>
563    If this option is set, PCRE's behaviour is changed in some ways so that it is
564    compatible with JavaScript rather than Perl. The changes are as follows:
565    </P>
566    <P>
567    (1) A lone closing square bracket in a pattern causes a compile-time error,
568    because this is illegal in JavaScript (by default it is treated as a data
569    character). Thus, the pattern AB]CD becomes illegal when this option is set.
570    </P>
571    <P>
572    (2) At run time, a back reference to an unset subpattern group matches an empty
573    string (by default this causes the current matching alternative to fail). A
574    pattern such as (\1)(a) succeeds when this option is set (assuming it can find
575    an "a" in the subject), whereas it fails by default, for Perl compatibility.
576    <pre>
577    PCRE_MULTILINE    PCRE_MULTILINE
578  </pre>  </pre>
579  By default, PCRE treats the subject string as consisting of a single line of  By default, PCRE treats the subject string as consisting of a single line of
# Line 546  occurrences of ^ or $ in a pattern, sett Line 594  occurrences of ^ or $ in a pattern, sett
594    PCRE_NEWLINE_CR    PCRE_NEWLINE_CR
595    PCRE_NEWLINE_LF    PCRE_NEWLINE_LF
596    PCRE_NEWLINE_CRLF    PCRE_NEWLINE_CRLF
597      PCRE_NEWLINE_ANYCRLF
598    PCRE_NEWLINE_ANY    PCRE_NEWLINE_ANY
599  </pre>  </pre>
600  These options override the default newline definition that was chosen when PCRE  These options override the default newline definition that was chosen when PCRE
601  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
602  indicated by a single character (CR or LF, respectively). Setting  indicated by a single character (CR or LF, respectively). Setting
603  PCRE_NEWLINE_CRLF specifies that a newline is indicated by the two-character  PCRE_NEWLINE_CRLF specifies that a newline is indicated by the two-character
604  CRLF sequence. Setting PCRE_NEWLINE_ANY specifies that any Unicode newline  CRLF sequence. Setting PCRE_NEWLINE_ANYCRLF specifies that any of the three
605  sequence should be recognized. The Unicode newline sequences are the three just  preceding sequences should be recognized. Setting PCRE_NEWLINE_ANY specifies
606  mentioned, plus the single characters VT (vertical tab, U+000B), FF (formfeed,  that any Unicode newline sequence should be recognized. The Unicode newline
607  U+000C), NEL (next line, U+0085), LS (line separator, U+2028), and PS  sequences are the three just mentioned, plus the single characters VT (vertical
608  (paragraph separator, U+2029). The last two are recognized only in UTF-8 mode.  tab, U+000B), FF (formfeed, U+000C), NEL (next line, U+0085), LS (line
609    separator, U+2028), and PS (paragraph separator, U+2029). The last two are
610    recognized only in UTF-8 mode.
611  </P>  </P>
612  <P>  <P>
613  The newline setting in the options word uses three bits that are treated  The newline setting in the options word uses three bits that are treated
614  as a number, giving eight possibilities. Currently only five are used (default  as a number, giving eight possibilities. Currently only six are used (default
615  plus the four values above). This means that if you set more than one newline  plus the five values above). This means that if you set more than one newline
616  option, the combination may or may not be sensible. For example,  option, the combination may or may not be sensible. For example,
617  PCRE_NEWLINE_CR with PCRE_NEWLINE_LF is equivalent to PCRE_NEWLINE_CRLF, but  PCRE_NEWLINE_CR with PCRE_NEWLINE_LF is equivalent to PCRE_NEWLINE_CRLF, but
618  other combinations yield unused numbers and cause an error.  other combinations may yield unused numbers and cause an error.
619  </P>  </P>
620  <P>  <P>
621  The only time that a line break is specially recognized when compiling a  The only time that a line break is specially recognized when compiling a
# Line 607  page. Line 658  page.
658    PCRE_NO_UTF8_CHECK    PCRE_NO_UTF8_CHECK
659  </pre>  </pre>
660  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
661  automatically checked. If an invalid UTF-8 sequence of bytes is found,  automatically checked. There is a discussion about the
662  <b>pcre_compile()</b> returns an error. If you already know that your pattern is  <a href="pcre.html#utf8strings">validity of UTF-8 strings</a>
663  valid, and you want to skip this check for performance reasons, you can set the  in the main
664  PCRE_NO_UTF8_CHECK option. When it is set, the effect of passing an invalid  <a href="pcre.html"><b>pcre</b></a>
665  UTF-8 string as a pattern is undefined. It may cause your program to crash.  page. If an invalid UTF-8 sequence of bytes is found, <b>pcre_compile()</b>
666  Note that this option can also be passed to <b>pcre_exec()</b> and  returns an error. If you already know that your pattern is valid, and you want
667  <b>pcre_dfa_exec()</b>, to suppress the UTF-8 validity checking of subject  to skip this check for performance reasons, you can set the PCRE_NO_UTF8_CHECK
668  strings.  option. When it is set, the effect of passing an invalid UTF-8 string as a
669    pattern is undefined. It may cause your program to crash. Note that this option
670    can also be passed to <b>pcre_exec()</b> and <b>pcre_dfa_exec()</b>, to suppress
671    the UTF-8 validity checking of subject strings.
672  </P>  </P>
673  <br><a name="SEC8" href="#TOC1">COMPILATION ERROR CODES</a><br>  <br><a name="SEC8" href="#TOC1">COMPILATION ERROR CODES</a><br>
674  <P>  <P>
# Line 635  out of use. To avoid confusion, they hav Line 689  out of use. To avoid confusion, they hav
689     9  nothing to repeat     9  nothing to repeat
690    10  [this code is not in use]    10  [this code is not in use]
691    11  internal error: unexpected repeat    11  internal error: unexpected repeat
692    12  unrecognized character after (?    12  unrecognized character after (? or (?-
693    13  POSIX named classes are supported only within a class    13  POSIX named classes are supported only within a class
694    14  missing )    14  missing )
695    15  reference to non-existent subpattern    15  reference to non-existent subpattern
# Line 643  out of use. To avoid confusion, they hav Line 697  out of use. To avoid confusion, they hav
697    17  unknown option bit(s) set    17  unknown option bit(s) set
698    18  missing ) after comment    18  missing ) after comment
699    19  [this code is not in use]    19  [this code is not in use]
700    20  regular expression too large    20  regular expression is too large
701    21  failed to get memory    21  failed to get memory
702    22  unmatched parentheses    22  unmatched parentheses
703    23  internal error: code overflow    23  internal error: code overflow
# Line 652  out of use. To avoid confusion, they hav Line 706  out of use. To avoid confusion, they hav
706    26  malformed number or name after (?(    26  malformed number or name after (?(
707    27  conditional group contains more than two branches    27  conditional group contains more than two branches
708    28  assertion expected after (?(    28  assertion expected after (?(
709    29  (?R or (?digits must be followed by )    29  (?R or (?[+-]digits must be followed by )
710    30  unknown POSIX class name    30  unknown POSIX class name
711    31  POSIX collating elements are not supported    31  POSIX collating elements are not supported
712    32  this version of PCRE is not compiled with PCRE_UTF8 support    32  this version of PCRE is not compiled with PCRE_UTF8 support
# Line 672  out of use. To avoid confusion, they hav Line 726  out of use. To avoid confusion, they hav
726    46  malformed \P or \p sequence    46  malformed \P or \p sequence
727    47  unknown property name after \P or \p    47  unknown property name after \P or \p
728    48  subpattern name is too long (maximum 32 characters)    48  subpattern name is too long (maximum 32 characters)
729    49  too many named subpatterns (maximum 10,000)    49  too many named subpatterns (maximum 10000)
730    50  repeated subpattern is too long    50  [this code is not in use]
731    51  octal value is greater than \377 (not in UTF-8 mode)    51  octal value is greater than \377 (not in UTF-8 mode)
732    52  internal error: overran compiling workspace    52  internal error: overran compiling workspace
733    53  internal error: previously-checked referenced subpattern not found    53  internal error: previously-checked referenced subpattern not found
734    54  DEFINE group contains more than one branch    54  DEFINE group contains more than one branch
735    55  repeating a DEFINE group is not allowed    55  repeating a DEFINE group is not allowed
736    56  inconsistent NEWLINE options"    56  inconsistent NEWLINE options
737  </PRE>    57  \g is not followed by a braced, angle-bracketed, or quoted
738            name/number or by a plain number
739      58  a numbered reference must not be zero
740      59  (*VERB) with an argument is not supported
741      60  (*VERB) not recognized
742      61  number is too big
743      62  subpattern name expected
744      63  digit expected after (?+
745      64  ] is an invalid data character in JavaScript compatibility mode
746    </pre>
747    The numbers 32 and 10000 in errors 48 and 49 are defaults; different values may
748    be used if the limits were changed when PCRE was built.
749  </P>  </P>
750  <br><a name="SEC9" href="#TOC1">STUDYING A PATTERN</a><br>  <br><a name="SEC9" href="#TOC1">STUDYING A PATTERN</a><br>
751  <P>  <P>
# Line 737  bytes is created. Line 802  bytes is created.
802  <a name="localesupport"></a></P>  <a name="localesupport"></a></P>
803  <br><a name="SEC10" href="#TOC1">LOCALE SUPPORT</a><br>  <br><a name="SEC10" href="#TOC1">LOCALE SUPPORT</a><br>
804  <P>  <P>
805  PCRE handles caseless matching, and determines whether characters are letters  PCRE handles caseless matching, and determines whether characters are letters,
806  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
807  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
808  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
809  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
810  support. The use of locales with Unicode is discouraged.  support. The use of locales with Unicode is discouraged. If you are handling
811  </P>  characters with codes greater than 128, you should either use UTF-8 and
812  <P>  Unicode, or use locales, but not try to mix the two.
813  An internal set of tables is created in the default C locale when PCRE is  </P>
814  built. This is used when the final argument of <b>pcre_compile()</b> is NULL,  <P>
815  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
816  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.
817  default. As more and more applications change to using Unicode, the need for  Normally, the internal tables recognize only ASCII characters. However, when
818  this locale support is expected to die away.  PCRE is built, it is possible to cause the internal tables to be rebuilt in the
819    default "C" locale of the local system, which may cause them to be different.
820    </P>
821    <P>
822    The internal tables can always be overridden by tables supplied by the
823    application that calls PCRE. These may be created in a different locale from
824    the default. As more and more applications change to using Unicode, the need
825    for this locale support is expected to die away.
826  </P>  </P>
827  <P>  <P>
828  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 764  the following code could be used: Line 836  the following code could be used:
836    tables = pcre_maketables();    tables = pcre_maketables();
837    re = pcre_compile(..., tables);    re = pcre_compile(..., tables);
838  </pre>  </pre>
839    The locale name "fr_FR" is used on Linux and other Unix-like systems; if you
840    are using Windows, the name for the French locale is "french".
841    </P>
842    <P>
843  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
844  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
845  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 871  table indicating a fixed set of bytes fo Line 947  table indicating a fixed set of bytes fo
947  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
948  fourth argument should point to an <b>unsigned char *</b> variable.  fourth argument should point to an <b>unsigned char *</b> variable.
949  <pre>  <pre>
950      PCRE_INFO_HASCRORLF
951    </pre>
952    Return 1 if the pattern contains any explicit matches for CR or LF characters,
953    otherwise 0. The fourth argument should point to an <b>int</b> variable. An
954    explicit match is either a literal CR or LF character, or \r or \n.
955    <pre>
956      PCRE_INFO_JCHANGED
957    </pre>
958    Return 1 if the (?J) or (?-J) option setting is used in the pattern, otherwise
959    0. The fourth argument should point to an <b>int</b> variable. (?J) and
960    (?-J) set and unset the local PCRE_DUPNAMES option, respectively.
961    <pre>
962    PCRE_INFO_LASTLITERAL    PCRE_INFO_LASTLITERAL
963  </pre>  </pre>
964  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 922  When writing code to extract data from n Line 1010  When writing code to extract data from n
1010  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
1011  different for each compiled pattern.  different for each compiled pattern.
1012  <pre>  <pre>
1013      PCRE_INFO_OKPARTIAL
1014    </pre>
1015    Return 1 if the pattern can be used for partial matching, otherwise 0. The
1016    fourth argument should point to an <b>int</b> variable. The
1017    <a href="pcrepartial.html"><b>pcrepartial</b></a>
1018    documentation lists the restrictions that apply to patterns when partial
1019    matching is used.
1020    <pre>
1021    PCRE_INFO_OPTIONS    PCRE_INFO_OPTIONS
1022  </pre>  </pre>
1023  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
1024  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
1025  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
1026  top-level option settings within the pattern itself.  top-level option settings at the start of the pattern itself. In other words,
1027    they are the options that will be in force when matching starts. For example,
1028    if the pattern /(?im)abc(?-i)d/ is compiled with the PCRE_EXTENDED option, the
1029    result is PCRE_CASELESS, PCRE_MULTILINE, and PCRE_EXTENDED.
1030  </P>  </P>
1031  <P>  <P>
1032  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 1136  the external tables might be at a differ Line 1235  the external tables might be at a differ
1235  called. See the  called. See the
1236  <a href="pcreprecompile.html"><b>pcreprecompile</b></a>  <a href="pcreprecompile.html"><b>pcreprecompile</b></a>
1237  documentation for a discussion of saving compiled patterns for later use.  documentation for a discussion of saving compiled patterns for later use.
1238  </P>  <a name="execoptions"></a></P>
1239  <br><b>  <br><b>
1240  Option bits for <b>pcre_exec()</b>  Option bits for <b>pcre_exec()</b>
1241  </b><br>  </b><br>
# Line 1152  matching position. If a pattern was comp Line 1251  matching position. If a pattern was comp
1251  to be anchored by virtue of its contents, it cannot be made unachored at  to be anchored by virtue of its contents, it cannot be made unachored at
1252  matching time.  matching time.
1253  <pre>  <pre>
1254      PCRE_BSR_ANYCRLF
1255      PCRE_BSR_UNICODE
1256    </pre>
1257    These options (which are mutually exclusive) control what the \R escape
1258    sequence matches. The choice is either to match only CR, LF, or CRLF, or to
1259    match any Unicode newline sequence. These options override the choice that was
1260    made or defaulted when the pattern was compiled.
1261    <pre>
1262    PCRE_NEWLINE_CR    PCRE_NEWLINE_CR
1263    PCRE_NEWLINE_LF    PCRE_NEWLINE_LF
1264    PCRE_NEWLINE_CRLF    PCRE_NEWLINE_CRLF
1265      PCRE_NEWLINE_ANYCRLF
1266    PCRE_NEWLINE_ANY    PCRE_NEWLINE_ANY
1267  </pre>  </pre>
1268  These options override the newline definition that was chosen or defaulted when  These options override the newline definition that was chosen or defaulted when
# Line 1162  the pattern was compiled. For details, s Line 1270  the pattern was compiled. For details, s
1270  <b>pcre_compile()</b> above. During matching, the newline choice affects the  <b>pcre_compile()</b> above. During matching, the newline choice affects the
1271  behaviour of the dot, circumflex, and dollar metacharacters. It may also alter  behaviour of the dot, circumflex, and dollar metacharacters. It may also alter
1272  the way the match position is advanced after a match failure for an unanchored  the way the match position is advanced after a match failure for an unanchored
1273  pattern. When PCRE_NEWLINE_CRLF or PCRE_NEWLINE_ANY is set, and a match attempt  pattern.
1274  fails when the current position is at a CRLF sequence, the match position is  </P>
1275  advanced by two characters instead of one, in other words, to after the CRLF.  <P>
1276    When PCRE_NEWLINE_CRLF, PCRE_NEWLINE_ANYCRLF, or PCRE_NEWLINE_ANY is set, and a
1277    match attempt for an unanchored pattern fails when the current position is at a
1278    CRLF sequence, and the pattern contains no explicit matches for CR or LF
1279    characters, the match position is advanced by two characters instead of one, in
1280    other words, to after the CRLF.
1281    </P>
1282    <P>
1283    The above rule is a compromise that makes the most common cases work as
1284    expected. For example, if the pattern is .+A (and the PCRE_DOTALL option is not
1285    set), it does not match the string "\r\nA" because, after failing at the
1286    start, it skips both the CR and the LF before retrying. However, the pattern
1287    [\r\n]A does match that string, because it contains an explicit CR or LF
1288    reference, and so advances only by one character after the first failure.
1289    </P>
1290    <P>
1291    An explicit match for CR of LF is either a literal appearance of one of those
1292    characters, or one of the \r or \n escape sequences. Implicit matches such as
1293    [^X] do not count, nor does \s (which includes CR and LF in the characters
1294    that it matches).
1295    </P>
1296    <P>
1297    Notwithstanding the above, anomalous effects may still occur when CRLF is a
1298    valid newline sequence and explicit \r or \n escapes appear in the pattern.
1299  <pre>  <pre>
1300    PCRE_NOTBOL    PCRE_NOTBOL
1301  </pre>  </pre>
# Line 1208  code that demonstrates how to do this in Line 1339  code that demonstrates how to do this in
1339  When PCRE_UTF8 is set at compile time, the validity of the subject as a UTF-8  When PCRE_UTF8 is set at compile time, the validity of the subject as a UTF-8
1340  string is automatically checked when <b>pcre_exec()</b> is subsequently called.  string is automatically checked when <b>pcre_exec()</b> is subsequently called.
1341  The value of <i>startoffset</i> is also checked to ensure that it points to the  The value of <i>startoffset</i> is also checked to ensure that it points to the
1342  start of a UTF-8 character. If an invalid UTF-8 sequence of bytes is found,  start of a UTF-8 character. There is a discussion about the validity of UTF-8
1343  <b>pcre_exec()</b> returns the error PCRE_ERROR_BADUTF8. If <i>startoffset</i>  strings in the
1344  contains an invalid value, PCRE_ERROR_BADUTF8_OFFSET is returned.  <a href="pcre.html#utf8strings">section on UTF-8 support</a>
1345    in the main
1346    <a href="pcre.html"><b>pcre</b></a>
1347    page. If an invalid UTF-8 sequence of bytes is found, <b>pcre_exec()</b> returns
1348    the error PCRE_ERROR_BADUTF8. If <i>startoffset</i> contains an invalid value,
1349    PCRE_ERROR_BADUTF8_OFFSET is returned.
1350  </P>  </P>
1351  <P>  <P>
1352  If you already know that your subject is valid, and you want to skip these  If you already know that your subject is valid, and you want to skip these
# Line 1448  The internal recursion limit, as specifi Line 1584  The internal recursion limit, as specifi
1584  field in a <b>pcre_extra</b> structure (or defaulted) was reached. See the  field in a <b>pcre_extra</b> structure (or defaulted) was reached. See the
1585  description above.  description above.
1586  <pre>  <pre>
   PCRE_ERROR_NULLWSLIMIT    (-22)  
 </pre>  
 When a group that can match an empty substring is repeated with an unbounded  
 upper limit, the subject position at the start of the group must be remembered,  
 so that a test for an empty string can be made when the end of the group is  
 reached. Some workspace is required for this; if it runs out, this error is  
 given.  
 <pre>  
1587    PCRE_ERROR_BADNEWLINE     (-23)    PCRE_ERROR_BADNEWLINE     (-23)
1588  </pre>  </pre>
1589  An invalid combination of PCRE_NEWLINE_<i>xxx</i> options was given.  An invalid combination of PCRE_NEWLINE_<i>xxx</i> options was given.
1590  </P>  </P>
1591  <P>  <P>
1592  Error numbers -16 to -20 are not used by <b>pcre_exec()</b>.  Error numbers -16 to -20 and -22 are not used by <b>pcre_exec()</b>.
1593  </P>  </P>
1594  <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>
1595  <P>  <P>
# Line 1607  translation table. Line 1735  translation table.
1735  </P>  </P>
1736  <P>  <P>
1737  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
1738  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
1739  appropriate.  appropriate. <b>NOTE:</b> If PCRE_DUPNAMES is set and there are duplicate names,
1740    the behaviour may not be what you want (see the next section).
1741  </P>  </P>
1742  <br><a name="SEC17" href="#TOC1">DUPLICATE SUBPATTERN NAMES</a><br>  <br><a name="SEC17" href="#TOC1">DUPLICATE SUBPATTERN NAMES</a><br>
1743  <P>  <P>
# Line 1621  are not required to be unique. Normally, Line 1750  are not required to be unique. Normally,
1750  that in any one match, only one of the named subpatterns participates. An  that in any one match, only one of the named subpatterns participates. An
1751  example is shown in the  example is shown in the
1752  <a href="pcrepattern.html"><b>pcrepattern</b></a>  <a href="pcrepattern.html"><b>pcrepattern</b></a>
1753  documentation. When duplicates are present, <b>pcre_copy_named_substring()</b>  documentation.
1754  and <b>pcre_get_named_substring()</b> return the first substring corresponding  </P>
1755  to the given name that is set. If none are set, an empty string is returned.  <P>
1756  The <b>pcre_get_stringnumber()</b> function returns one of the numbers that are  When duplicates are present, <b>pcre_copy_named_substring()</b> and
1757  associated with the name, but it is not defined which it is.  <b>pcre_get_named_substring()</b> return the first substring corresponding to
1758  <br>  the given name that is set. If none are set, PCRE_ERROR_NOSUBSTRING (-7) is
1759  <br>  returned; no data is returned. The <b>pcre_get_stringnumber()</b> function
1760    returns one of the numbers that are associated with the name, but it is not
1761    defined which it is.
1762    </P>
1763    <P>
1764  If you want to get full details of all captured substrings for a given name,  If you want to get full details of all captured substrings for a given name,
1765  you must use the <b>pcre_get_stringtable_entries()</b> function. The first  you must use the <b>pcre_get_stringtable_entries()</b> function. The first
1766  argument is the compiled pattern, and the second is the name. The third and  argument is the compiled pattern, and the second is the name. The third and
# Line 1839  Cambridge CB2 3QH, England. Line 1972  Cambridge CB2 3QH, England.
1972  </P>  </P>
1973  <br><a name="SEC22" href="#TOC1">REVISION</a><br>  <br><a name="SEC22" href="#TOC1">REVISION</a><br>
1974  <P>  <P>
1975  Last updated: 06 March 2007  Last updated: 12 April 2008
1976  <br>  <br>
1977  Copyright &copy; 1997-2007 University of Cambridge.  Copyright &copy; 1997-2008 University of Cambridge.
1978  <br>  <br>
1979  <p>  <p>
1980  Return to the <a href="index.html">PCRE index page</a>.  Return to the <a href="index.html">PCRE index page</a>.

Legend:
Removed from v.99  
changed lines
  Added in v.345

  ViewVC Help
Powered by ViewVC 1.1.5