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

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

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

revision 1298 by ph10, Fri Mar 22 16:13:13 2013 UTC revision 1302 by ph10, Wed Mar 27 11:13:36 2013 UTC
# Line 1  Line 1 
1  .TH PCREPATTERN 3 "22 March 2013" "PCRE 8.33"  .TH PCREPATTERN 3 "27 March 2013" "PCRE 8.33"
2  .SH NAME  .SH NAME
3  PCRE - Perl-compatible regular expressions  PCRE - Perl-compatible regular expressions
4  .SH "PCRE REGULAR EXPRESSION DETAILS"  .SH "PCRE REGULAR EXPRESSION DETAILS"
# Line 2673  remarks apply to the PCRE features descr Line 2673  remarks apply to the PCRE features descr
2673  .P  .P
2674  The new verbs make use of what was previously invalid syntax: an opening  The new verbs make use of what was previously invalid syntax: an opening
2675  parenthesis followed by an asterisk. They are generally of the form  parenthesis followed by an asterisk. They are generally of the form
2676  (*VERB) or (*VERB:NAME). Some may take either form, with differing behaviour,  (*VERB) or (*VERB:NAME). Some may take either form, possibly behaving
2677  depending on whether or not a name is present. A name is any sequence of  differently depending on whether or not a name is present. A name is any
2678  characters that does not include a closing parenthesis. The maximum length of  sequence of characters that does not include a closing parenthesis. The maximum
2679  name is 255 in the 8-bit library and 65535 in the 16-bit and 32-bit libraries.  length of name is 255 in the 8-bit library and 65535 in the 16-bit and 32-bit
2680  If the name is empty, that is, if the closing parenthesis immediately follows  libraries. If the name is empty, that is, if the closing parenthesis
2681  the colon, the effect is as if the colon were not there. Any number of these  immediately follows the colon, the effect is as if the colon were not there.
2682  verbs may occur in a pattern.  Any number of these verbs may occur in a pattern.
2683  .P  .P
2684  Since these verbs are specifically related to backtracking, most of them can be  Since these verbs are specifically related to backtracking, most of them can be
2685  used only when the pattern is to be matched using one of the traditional  used only when the pattern is to be matched using one of the traditional
# Line 2807  indicates which of the two alternatives Line 2807  indicates which of the two alternatives
2807  of obtaining this information than putting each alternative in its own  of obtaining this information than putting each alternative in its own
2808  capturing parentheses.  capturing parentheses.
2809  .P  .P
2810  If a verb with a name is encountered in a positive assertion, its name is  If a verb with a name is encountered in a positive assertion that is true, the
2811  recorded and passed back if it is the last-encountered. This does not happen  name is recorded and passed back if it is the last-encountered. This does not
2812  for negative assertions.  happen for negative assertions or failing positive assertions.
2813  .P  .P
2814  After a partial match or a failed match, the last encountered name in the  After a partial match or a failed match, the last encountered name in the
2815  entire match process is returned. For example:  entire match process is returned. For example:
# Line 2839  The following verbs do nothing when they Line 2839  The following verbs do nothing when they
2839  with what follows, but if there is no subsequent match, causing a backtrack to  with what follows, but if there is no subsequent match, causing a backtrack to
2840  the verb, a failure is forced. That is, backtracking cannot pass to the left of  the verb, a failure is forced. That is, backtracking cannot pass to the left of
2841  the verb. However, when one of these verbs appears inside an atomic group or an  the verb. However, when one of these verbs appears inside an atomic group or an
2842  assertion, its effect is confined to that group, because once the group has  assertion that is true, its effect is confined to that group, because once the
2843  been matched, there is never any backtracking into it. In this situation,  group has been matched, there is never any backtracking into it. In this
2844  backtracking can "jump back" to the left of the entire atomic group or  situation, backtracking can "jump back" to the left of the entire atomic group
2845  assertion. (Remember also, as stated above, that this localization also applies  or assertion. (Remember also, as stated above, that this localization also
2846  in subroutine calls.)  applies in subroutine calls.)
2847  .P  .P
2848  These verbs differ in exactly what kind of failure occurs when backtracking  These verbs differ in exactly what kind of failure occurs when backtracking
2849  reaches them.  reaches them. The behaviour described below is what happens when the verb is
2850    not in a subroutine or an assertion. Subsequent sections cover these special
2851    cases.
2852  .sp  .sp
2853    (*COMMIT)    (*COMMIT)
2854  .sp  .sp
# Line 2942  pattern-based if-then-else block: Line 2944  pattern-based if-then-else block:
2944  .sp  .sp
2945  If the COND1 pattern matches, FOO is tried (and possibly further items after  If the COND1 pattern matches, FOO is tried (and possibly further items after
2946  the end of the group if FOO succeeds); on failure, the matcher skips to the  the end of the group if FOO succeeds); on failure, the matcher skips to the
2947  second alternative and tries COND2, without backtracking into COND1.  second alternative and tries COND2, without backtracking into COND1. If that
2948  If (*THEN) is not inside an alternation, it acts like (*PRUNE).  succeeds and BAR fails, COND3 is tried. If subsequently BAZ fails, there are no
2949    more alternatives, so there is a backtrack to whatever came before the entire
2950    group. If (*THEN) is not inside an alternation, it acts like (*PRUNE).
2951  .P  .P
2952  The behaviour of (*THEN:NAME) is the not the same as (*MARK:NAME)(*THEN).  The behaviour of (*THEN:NAME) is the not the same as (*MARK:NAME)(*THEN).
2953  It is like (*MARK:NAME) in that the name is remembered for passing back to the  It is like (*MARK:NAME) in that the name is remembered for passing back to the
# Line 3039  the second repeat of the group acts. Line 3043  the second repeat of the group acts.
3043  further processing. In a negative assertion, (*ACCEPT) causes the assertion to  further processing. In a negative assertion, (*ACCEPT) causes the assertion to
3044  fail without any further processing.  fail without any further processing.
3045  .P  .P
3046  The other backtracking verbs are not treated specially if they appear in an  The other backtracking verbs are not treated specially if they appear in a
3047  assertion. In particular, (*THEN) skips to the next alternative in the  positive assertion. In particular, (*THEN) skips to the next alternative in the
3048  innermost enclosing group that has alternations, whether or not this is within  innermost enclosing group that has alternations, whether or not this is within
3049  the assertion.  the assertion.
3050    .P
3051    Negative assertions are, however, different, in order to ensure that changing a
3052    positive assertion into a negative assertion changes its result. Backtracking
3053    into (*COMMIT), (*SKIP), or (*PRUNE) causes a negative assertion to be true,
3054    without considering any further alternative branches in the assertion.
3055    Backtracking into (*THEN) causes it to skip to the next enclosing alternative
3056    within the assertion (the normal behaviour), but if the assertion does not have
3057    such an alternative, (*THEN) behaves like (*PRUNE).
3058  .  .
3059  .  .
3060  .\" HTML <a name="btsub"></a>  .\" HTML <a name="btsub"></a>
# Line 3088  Cambridge CB2 3QH, England. Line 3100  Cambridge CB2 3QH, England.
3100  .rs  .rs
3101  .sp  .sp
3102  .nf  .nf
3103  Last updated: 22 March 2013  Last updated: 27 March 2013
3104  Copyright (c) 1997-2013 University of Cambridge.  Copyright (c) 1997-2013 University of Cambridge.
3105  .fi  .fi

Legend:
Removed from v.1298  
changed lines
  Added in v.1302

  ViewVC Help
Powered by ViewVC 1.1.5