/[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 128 by ph10, Tue Mar 20 11:46:50 2007 UTC revision 202 by ph10, Fri Aug 3 09:44:26 2007 UTC
# Line 246  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 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 286  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 317  properties is available; otherwise it is Line 320  properties is available; otherwise it is
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 four values that are supported  that is recognized as meaning "newline". The four values that are supported
323  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
324  normally be 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 546  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    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  indicated by a single character (CR or LF, respectively). Setting
558  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
559  CRLF sequence. Setting PCRE_NEWLINE_ANY specifies that any Unicode newline  CRLF sequence. Setting PCRE_NEWLINE_ANYCRLF specifies that any of the three
560  sequence should be recognized. The Unicode newline sequences are the three just  preceding sequences should be recognized. Setting PCRE_NEWLINE_ANY specifies
561  mentioned, plus the single characters VT (vertical tab, U+000B), FF (formfeed,  that any Unicode newline sequence should be recognized. The Unicode newline
562  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
563  (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
564    separator, U+2028), and PS (paragraph separator, U+2029). The last two are
565    recognized only in UTF-8 mode.
566  </P>  </P>
567  <P>  <P>
568  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
569  as a number, giving eight possibilities. Currently only five are used (default  as a number, giving eight possibilities. Currently only six are used (default
570  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
571  option, the combination may or may not be sensible. For example,  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  PCRE_NEWLINE_CR with PCRE_NEWLINE_LF is equivalent to PCRE_NEWLINE_CRLF, but
573  other combinations yield unused numbers and cause an error.  other combinations may yield unused numbers and cause an error.
574  </P>  </P>
575  <P>  <P>
576  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 652  out of use. To avoid confusion, they hav Line 658  out of use. To avoid confusion, they hav
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
# Line 673  out of use. To avoid confusion, they hav Line 679  out of use. To avoid confusion, they hav
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    52  internal error: overran compiling workspace
685    53  internal error: previously-checked referenced subpattern not found    53  internal error: previously-checked referenced subpattern not found
686    54  DEFINE group contains more than one branch    54  DEFINE group contains more than one branch
687    55  repeating a DEFINE group is not allowed    55  repeating a DEFINE group is not allowed
688    56  inconsistent NEWLINE options"    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 737  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 764  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 871  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 922  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 1155  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    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
# Line 1162  the pattern was compiled. For details, s Line 1200  the pattern was compiled. For details, s
1200  <b>pcre_compile()</b> above. During matching, the newline choice affects the  <b>pcre_compile()</b> above. During matching, the newline choice affects the
1201  behaviour of the dot, circumflex, and dollar metacharacters. It may also alter  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  the way the match position is advanced after a match failure for an unanchored
1203  pattern. When PCRE_NEWLINE_CRLF or PCRE_NEWLINE_ANY is set, and a match attempt  pattern. When PCRE_NEWLINE_CRLF, PCRE_NEWLINE_ANYCRLF, or PCRE_NEWLINE_ANY is
1204  fails when the current position is at a CRLF sequence, the match position is  set, and a match attempt fails when the current position is at a CRLF sequence,
1205  advanced by two characters instead of one, in other words, to after the CRLF.  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 1448  The internal recursion limit, as specifi Line 1487  The internal recursion limit, as specifi
1487  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
1488  description above.  description above.
1489  <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>  
1490    PCRE_ERROR_BADNEWLINE     (-23)    PCRE_ERROR_BADNEWLINE     (-23)
1491  </pre>  </pre>
1492  An invalid combination of PCRE_NEWLINE_<i>xxx</i> options was given.  An invalid combination of PCRE_NEWLINE_<i>xxx</i> options was given.
1493  </P>  </P>
1494  <P>  <P>
1495  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>.
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 1840  Cambridge CB2 3QH, England. Line 1871  Cambridge CB2 3QH, England.
1871  </P>  </P>
1872  <br><a name="SEC22" href="#TOC1">REVISION</a><br>  <br><a name="SEC22" href="#TOC1">REVISION</a><br>
1873  <P>  <P>
1874  Last updated: 06 March 2007  Last updated: 30 July 2007
1875  <br>  <br>
1876  Copyright &copy; 1997-2007 University of Cambridge.  Copyright &copy; 1997-2007 University of Cambridge.
1877  <br>  <br>

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

  ViewVC Help
Powered by ViewVC 1.1.5