/[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 178 by ph10, Wed Jun 13 08:44:34 2007 UTC revision 184 by ph10, Tue Jun 19 13:26:46 2007 UTC
# Line 260  parenthesized subpatterns. Line 260  parenthesized subpatterns.
260  Another use of backslash is for specifying generic character types. The  Another use of backslash is for specifying generic character types. The
261  following are always recognized:  following are always recognized:
262  .sp  .sp
263    \ed     any decimal digit    \ed     any decimal digit
264    \eD     any character that is not a decimal digit    \eD     any character that is not a decimal digit
265    \eh     any horizontal whitespace character    \eh     any horizontal whitespace character
266    \eH     any character that is not a horizontal whitespace character    \eH     any character that is not a horizontal whitespace character
267    \es     any whitespace character    \es     any whitespace character
268    \eS     any character that is not a whitespace character    \eS     any character that is not a whitespace character
269    \ev     any vertical whitespace character    \ev     any vertical whitespace character
270    \eV     any character that is not a vertical whitespace character    \eV     any character that is not a vertical whitespace character
271    \ew     any "word" character    \ew     any "word" character
272    \eW     any "non-word" character    \eW     any "non-word" character
273  .sp  .sp
# Line 287  does. Line 287  does.
287  .P  .P
288  In UTF-8 mode, characters with values greater than 128 never match \ed, \es, or  In UTF-8 mode, characters with values greater than 128 never match \ed, \es, or
289  \ew, and always match \eD, \eS, and \eW. This is true even when Unicode  \ew, and always match \eD, \eS, and \eW. This is true even when Unicode
290  character property support is available. These sequences retain their original  character property support is available. These sequences retain their original
291  meanings from before UTF-8 support was available, mainly for efficiency  meanings from before UTF-8 support was available, mainly for efficiency
292  reasons.  reasons.
293  .P  .P
294  The sequences \eh, \eH, \ev, and \eV are Perl 5.10 features. In contrast to the  The sequences \eh, \eH, \ev, and \eV are Perl 5.10 features. In contrast to the
295  other sequences, these do match certain high-valued codepoints in UTF-8 mode.  other sequences, these do match certain high-valued codepoints in UTF-8 mode.
296  The horizontal space characters are:  The horizontal space characters are:
297  .sp  .sp
# Line 376  Inside a character class, \eR matches th Line 376  Inside a character class, \eR matches th
376  .rs  .rs
377  .sp  .sp
378  When PCRE is built with Unicode character property support, three additional  When PCRE is built with Unicode character property support, three additional
379  escape sequences to match character properties are available when UTF-8 mode  escape sequences that match characters with specific properties are available.
380  is selected. They are:  When not in UTF-8 mode, these sequences are of course limited to testing
381    characters whose codepoints are less than 256, but they do work in this mode.
382    The extra escape sequences are:
383  .sp  .sp
384    \ep{\fIxx\fP}   a character with the \fIxx\fP property    \ep{\fIxx\fP}   a character with the \fIxx\fP property
385    \eP{\fIxx\fP}   a character without the \fIxx\fP property    \eP{\fIxx\fP}   a character without the \fIxx\fP property
# Line 553  atomic group Line 555  atomic group
555  (see below).  (see below).
556  .\"  .\"
557  Characters with the "mark" property are typically accents that affect the  Characters with the "mark" property are typically accents that affect the
558  preceding character.  preceding character. None of them have codepoints less than 256, so in
559    non-UTF-8 mode \eX matches any one character.
560  .P  .P
561  Matching characters by Unicode property is not fast, because PCRE has to search  Matching characters by Unicode property is not fast, because PCRE has to search
562  a structure that contains data for over fifteen thousand characters. That is  a structure that contains data for over fifteen thousand characters. That is
# Line 1001  the above patterns match "SUNDAY" as wel Line 1004  the above patterns match "SUNDAY" as wel
1004  .SH "DUPLICATE SUBPATTERN NUMBERS"  .SH "DUPLICATE SUBPATTERN NUMBERS"
1005  .rs  .rs
1006  .sp  .sp
1007  Perl 5.10 introduced a feature whereby each alternative in a subpattern uses  Perl 5.10 introduced a feature whereby each alternative in a subpattern uses
1008  the same numbers for its capturing parentheses. Such a subpattern starts with  the same numbers for its capturing parentheses. Such a subpattern starts with
1009  (?| and is itself a non-capturing subpattern. For example, consider this  (?| and is itself a non-capturing subpattern. For example, consider this
1010  pattern:  pattern:
1011  .sp  .sp
1012    (?|(Sat)ur|(Sun))day    (?|(Sat)ur|(Sun))day
1013  .sp  .sp
1014  Because the two alternatives are inside a (?| group, both sets of capturing  Because the two alternatives are inside a (?| group, both sets of capturing
1015  parentheses are numbered one. Thus, when the pattern matches, you can look  parentheses are numbered one. Thus, when the pattern matches, you can look
1016  at captured substring number one, whichever alternative matched. This construct  at captured substring number one, whichever alternative matched. This construct
1017  is useful when you want to capture part, but not all, of one of a number of  is useful when you want to capture part, but not all, of one of a number of
1018  alternatives. Inside a (?| group, parentheses are numbered as usual, but the  alternatives. Inside a (?| group, parentheses are numbered as usual, but the
1019  number is reset at the start of each branch. The numbers of any capturing  number is reset at the start of each branch. The numbers of any capturing
1020  buffers that follow the subpattern start after the highest number used in any  buffers that follow the subpattern start after the highest number used in any
1021  branch. The following example is taken from the Perl documentation.  branch. The following example is taken from the Perl documentation.
1022  The numbers underneath show in which buffer the captured content will be  The numbers underneath show in which buffer the captured content will be
1023  stored.  stored.
1024  .sp  .sp
1025    # before  ---------------branch-reset----------- after    # before  ---------------branch-reset----------- after
1026    / ( a )  (?| x ( y ) z | (p (q) r) | (t) u (v) ) ( z ) /x    / ( a )  (?| x ( y ) z | (p (q) r) | (t) u (v) ) ( z ) /x
1027    # 1            2         2  3        2     3     4    # 1            2         2  3        2     3     4
1028  .sp  .sp
1029  A backreference or a recursive call to a numbered subpattern always refers to  A backreference or a recursive call to a numbered subpattern always refers to
1030  the first one in the pattern with the given number.  the first one in the pattern with the given number.
1031  .P  .P
# Line 1079  abbreviation. This pattern (ignoring the Line 1082  abbreviation. This pattern (ignoring the
1082    (?<DN>Sat)(?:urday)?    (?<DN>Sat)(?:urday)?
1083  .sp  .sp
1084  There are five capturing substrings, but only one is ever set after a match.  There are five capturing substrings, but only one is ever set after a match.
1085  (An alternative way of solving this problem is to use a "branch reset"  (An alternative way of solving this problem is to use a "branch reset"
1086  subpattern, as described in the previous section.)  subpattern, as described in the previous section.)
1087  .P  .P
1088  The convenience function for extracting the data by name returns the substring  The convenience function for extracting the data by name returns the substring
# Line 1973  Cambridge CB2 3QH, England. Line 1976  Cambridge CB2 3QH, England.
1976  .rs  .rs
1977  .sp  .sp
1978  .nf  .nf
1979  Last updated: 13 June 2007  Last updated: 19 June 2007
1980  Copyright (c) 1997-2007 University of Cambridge.  Copyright (c) 1997-2007 University of Cambridge.
1981  .fi  .fi

Legend:
Removed from v.178  
changed lines
  Added in v.184

  ViewVC Help
Powered by ViewVC 1.1.5