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

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

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

revision 542 by ph10, Tue Jun 15 08:49:47 2010 UTC revision 566 by ph10, Wed Nov 3 18:32:55 2010 UTC
# Line 765  out of use. To avoid confusion, they hav Line 765  out of use. To avoid confusion, they hav
765    50  [this code is not in use]    50  [this code is not in use]
766    51  octal value is greater than \e377 (not in UTF-8 mode)    51  octal value is greater than \e377 (not in UTF-8 mode)
767    52  internal error: overran compiling workspace    52  internal error: overran compiling workspace
768    53  internal error: previously-checked referenced subpattern not found    53  internal error: previously-checked referenced subpattern
769            not found
770    54  DEFINE group contains more than one branch    54  DEFINE group contains more than one branch
771    55  repeating a DEFINE group is not allowed    55  repeating a DEFINE group is not allowed
772    56  inconsistent NEWLINE options    56  inconsistent NEWLINE options
# Line 778  out of use. To avoid confusion, they hav Line 779  out of use. To avoid confusion, they hav
779    62  subpattern name expected    62  subpattern name expected
780    63  digit expected after (?+    63  digit expected after (?+
781    64  ] is an invalid data character in JavaScript compatibility mode    64  ] is an invalid data character in JavaScript compatibility mode
782    65  different names for subpatterns of the same number are not allowed    65  different names for subpatterns of the same number are
783            not allowed
784    66  (*MARK) must have an argument    66  (*MARK) must have an argument
785    67  this version of PCRE is not compiled with PCRE_UCP support    67  this version of PCRE is not compiled with PCRE_UCP support
786  .sp  .sp
# Line 846  Studying a pattern is also useful for no Line 848  Studying a pattern is also useful for no
848  single fixed starting character. A bitmap of possible starting bytes is  single fixed starting character. A bitmap of possible starting bytes is
849  created. This speeds up finding a position in the subject at which to start  created. This speeds up finding a position in the subject at which to start
850  matching.  matching.
851    .P
852    The two optimizations just described can be disabled by setting the
853    PCRE_NO_START_OPTIMIZE option when calling \fBpcre_exec()\fP or
854    \fBpcre_dfa_exec()\fP. You might want to do this if your pattern contains
855    callouts, or make use of (*MARK), and you make use of these in cases where
856    matching fails. See the discussion of PCRE_NO_START_OPTIMIZE
857    .\" HTML <a href="#execoptions">
858    .\" </a>
859    below.
860    .\"
861  .  .
862  .  .
863  .\" HTML <a name="localesupport"></a>  .\" HTML <a name="localesupport"></a>
# Line 1438  the Line 1450  the
1450  .\" HREF  .\" HREF
1451  \fBpcredemo\fP  \fBpcredemo\fP
1452  .\"  .\"
1453  sample program.  sample program. In the most general case, you have to check to see if the
1454    newline convention recognizes CRLF as a newline, and if so, and the current
1455    character is CR followed by LF, advance the starting offset by two characters
1456    instead of one.
1457  .sp  .sp
1458    PCRE_NO_START_OPTIMIZE    PCRE_NO_START_OPTIMIZE
1459  .sp  .sp
# Line 1446  There are a number of optimizations that Line 1461  There are a number of optimizations that
1461  a match, in order to speed up the process. For example, if it is known that an  a match, in order to speed up the process. For example, if it is known that an
1462  unanchored match must start with a specific character, it searches the subject  unanchored match must start with a specific character, it searches the subject
1463  for that character, and fails immediately if it cannot find it, without  for that character, and fails immediately if it cannot find it, without
1464  actually running the main matching function. This means that a special item  actually running the main matching function. This means that a special item
1465  such as (*COMMIT) at the start of a pattern is not considered until after a  such as (*COMMIT) at the start of a pattern is not considered until after a
1466  suitable starting point for the match has been found. When callouts are in use,  suitable starting point for the match has been found. When callouts or (*MARK)
1467  these "start-up" optimizations can cause them to be skipped if the pattern is  items are in use, these "start-up" optimizations can cause them to be skipped
1468  never actually used. The PCRE_NO_START_OPTIMIZE option disables the start-up  if the pattern is never actually used. The start-up optimizations are in effect
1469  optimizations, causing performance to suffer, but ensuring that the callouts do  a pre-scan of the subject that takes place before the pattern is run.
1470  occur, and that items such as (*COMMIT) are considered at every possible  .P
1471  starting position in the subject string.  The PCRE_NO_START_OPTIMIZE option disables the start-up optimizations, possibly
1472    causing performance to suffer, but ensuring that in cases where the result is
1473    "no match", the callouts do occur, and that items such as (*COMMIT) and (*MARK)
1474    are considered at every possible starting position in the subject string.
1475    Setting PCRE_NO_START_OPTIMIZE can change the outcome of a matching operation.
1476    Consider the pattern
1477    .sp
1478      (*COMMIT)ABC
1479    .sp
1480    When this is compiled, PCRE records the fact that a match must start with the
1481    character "A". Suppose the subject string is "DEFABC". The start-up
1482    optimization scans along the subject, finds "A" and runs the first match
1483    attempt from there. The (*COMMIT) item means that the pattern must match the
1484    current starting position, which in this case, it does. However, if the same
1485    match is run with PCRE_NO_START_OPTIMIZE set, the initial scan along the
1486    subject string does not happen. The first match attempt is run starting from
1487    "D" and when this fails, (*COMMIT) prevents any further matches being tried, so
1488    the overall result is "no match". If the pattern is studied, more start-up
1489    optimizations may be used. For example, a minimum length for the subject may be
1490    recorded. Consider the pattern
1491    .sp
1492      (*MARK:A)(X|Y)
1493    .sp
1494    The minimum length for a match is one character. If the subject is "ABC", there
1495    will be attempts to match "ABC", "BC", "C", and then finally an empty string.
1496    If the pattern is studied, the final attempt does not take place, because PCRE
1497    knows that the subject is too short, and so the (*MARK) is never encountered.
1498    In this case, studying the pattern does not affect the overall match result,
1499    which is still "no match", but it does affect the auxiliary information that is
1500    returned.
1501  .sp  .sp
1502    PCRE_NO_UTF8_CHECK    PCRE_NO_UTF8_CHECK
1503  .sp  .sp
# Line 1491  These options turn on the partial matchi Line 1535  These options turn on the partial matchi
1535  compatibility, PCRE_PARTIAL is a synonym for PCRE_PARTIAL_SOFT. A partial match  compatibility, PCRE_PARTIAL is a synonym for PCRE_PARTIAL_SOFT. A partial match
1536  occurs if the end of the subject string is reached successfully, but there are  occurs if the end of the subject string is reached successfully, but there are
1537  not enough subject characters to complete the match. If this happens when  not enough subject characters to complete the match. If this happens when
1538  PCRE_PARTIAL_HARD is set, \fBpcre_exec()\fP immediately returns  PCRE_PARTIAL_SOFT (but not PCRE_PARTIAL_HARD) is set, matching continues by
1539  PCRE_ERROR_PARTIAL. Otherwise, if PCRE_PARTIAL_SOFT is set, matching continues  testing any remaining alternatives. Only if no complete match can be found is
1540  by testing any other alternatives. Only if they all fail is PCRE_ERROR_PARTIAL  PCRE_ERROR_PARTIAL returned instead of PCRE_ERROR_NOMATCH. In other words,
1541  returned (instead of PCRE_ERROR_NOMATCH). The portion of the string that  PCRE_PARTIAL_SOFT says that the caller is prepared to handle a partial match,
1542  was inspected when the partial match was found is set as the first matching  but only if no complete match can be found.
1543  string. There is a more detailed discussion in the  .P
1544    If PCRE_PARTIAL_HARD is set, it overrides PCRE_PARTIAL_SOFT. In this case, if a
1545    partial match is found, \fBpcre_exec()\fP immediately returns
1546    PCRE_ERROR_PARTIAL, without considering any other alternatives. In other words,
1547    when PCRE_PARTIAL_HARD is set, a partial match is considered to be more
1548    important that an alternative complete match.
1549    .P
1550    In both cases, the portion of the string that was inspected when the partial
1551    match was found is set as the first matching string. There is a more detailed
1552    discussion of partial and multi-segment matching, with examples, in the
1553  .\" HREF  .\" HREF
1554  \fBpcrepartial\fP  \fBpcrepartial\fP
1555  .\"  .\"
# Line 2018  is converted into PCRE_ERROR_PARTIAL if Line 2071  is converted into PCRE_ERROR_PARTIAL if
2071  there have been no complete matches, but there is still at least one matching  there have been no complete matches, but there is still at least one matching
2072  possibility. The portion of the string that was inspected when the longest  possibility. The portion of the string that was inspected when the longest
2073  partial match was found is set as the first matching string in both cases.  partial match was found is set as the first matching string in both cases.
2074    There is a more detailed discussion of partial and multi-segment matching, with
2075    examples, in the
2076    .\" HREF
2077    \fBpcrepartial\fP
2078    .\"
2079    documentation.
2080  .sp  .sp
2081    PCRE_DFA_SHORTEST    PCRE_DFA_SHORTEST
2082  .sp  .sp
# Line 2137  Cambridge CB2 3QH, England. Line 2196  Cambridge CB2 3QH, England.
2196  .rs  .rs
2197  .sp  .sp
2198  .nf  .nf
2199  Last updated: 15 June 2010  Last updated: 01 November 2010
2200  Copyright (c) 1997-2010 University of Cambridge.  Copyright (c) 1997-2010 University of Cambridge.
2201  .fi  .fi

Legend:
Removed from v.542  
changed lines
  Added in v.566

  ViewVC Help
Powered by ViewVC 1.1.5