/[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 172 by ph10, Tue Jun 5 10:40:13 2007 UTC revision 185 by ph10, Tue Jun 19 13:39:46 2007 UTC
# Line 262  following are always recognized: Line 262  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
266      \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
270      \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 277  there is no character to match. Line 281  there is no character to match.
281  .P  .P
282  For compatibility with Perl, \es does not match the VT character (code 11).  For compatibility with Perl, \es does not match the VT character (code 11).
283  This makes it different from the the POSIX "space" class. The \es characters  This makes it different from the the POSIX "space" class. The \es characters
284  are HT (9), LF (10), FF (12), CR (13), and space (32). (If "use locale;" is  are HT (9), LF (10), FF (12), CR (13), and space (32). If "use locale;" is
285  included in a Perl script, \es may match the VT character. In PCRE, it never  included in a Perl script, \es may match the VT character. In PCRE, it never
286  does.)  does.
287    .P
288    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
290    character property support is available. These sequences retain their original
291    meanings from before UTF-8 support was available, mainly for efficiency
292    reasons.
293    .P
294    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.
296    The horizontal space characters are:
297    .sp
298      U+0009     Horizontal tab
299      U+0020     Space
300      U+00A0     Non-break space
301      U+1680     Ogham space mark
302      U+180E     Mongolian vowel separator
303      U+2000     En quad
304      U+2001     Em quad
305      U+2002     En space
306      U+2003     Em space
307      U+2004     Three-per-em space
308      U+2005     Four-per-em space
309      U+2006     Six-per-em space
310      U+2007     Figure space
311      U+2008     Punctuation space
312      U+2009     Thin space
313      U+200A     Hair space
314      U+202F     Narrow no-break space
315      U+205F     Medium mathematical space
316      U+3000     Ideographic space
317    .sp
318    The vertical space characters are:
319    .sp
320      U+000A     Linefeed
321      U+000B     Vertical tab
322      U+000C     Formfeed
323      U+000D     Carriage return
324      U+0085     Next line
325      U+2028     Line separator
326      U+2029     Paragraph separator
327  .P  .P
328  A "word" character is an underscore or any character less than 256 that is a  A "word" character is an underscore or any character less than 256 that is a
329  letter or digit. The definition of letters and digits is controlled by PCRE's  letter or digit. The definition of letters and digits is controlled by PCRE's
# Line 295  in the Line 339  in the
339  .\"  .\"
340  page). For example, in a French locale such as "fr_FR" in Unix-like systems,  page). For example, in a French locale such as "fr_FR" in Unix-like systems,
341  or "french" in Windows, some character codes greater than 128 are used for  or "french" in Windows, some character codes greater than 128 are used for
342  accented letters, and these are matched by \ew.  accented letters, and these are matched by \ew. The use of locales with Unicode
343  .P  is discouraged.
 In UTF-8 mode, characters with values greater than 128 never match \ed, \es, or  
 \ew, and always match \eD, \eS, and \eW. This is true even when Unicode  
 character property support is available. The use of locales with Unicode is  
 discouraged.  
344  .  .
345  .  .
346  .SS "Newline sequences"  .SS "Newline sequences"
347  .rs  .rs
348  .sp  .sp
349  Outside a character class, the escape sequence \eR matches any Unicode newline  Outside a character class, the escape sequence \eR matches any Unicode newline
350  sequence. This is an extension to Perl. In non-UTF-8 mode \eR is equivalent to  sequence. This is a Perl 5.10 feature. In non-UTF-8 mode \eR is equivalent to
351  the following:  the following:
352  .sp  .sp
353    (?>\er\en|\en|\ex0b|\ef|\er|\ex85)    (?>\er\en|\en|\ex0b|\ef|\er|\ex85)
# Line 336  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 513  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 958  is reached, an option setting in one bra Line 1001  is reached, an option setting in one bra
1001  the above patterns match "SUNDAY" as well as "Saturday".  the above patterns match "SUNDAY" as well as "Saturday".
1002  .  .
1003  .  .
1004    .SH "DUPLICATE SUBPATTERN NUMBERS"
1005    .rs
1006    .sp
1007    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
1009    (?| and is itself a non-capturing subpattern. For example, consider this
1010    pattern:
1011    .sp
1012      (?|(Sat)ur|(Sun))day
1013    .sp
1014    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
1016    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
1018    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
1020    buffers that follow the subpattern start after the highest number used in any
1021    branch. The following example is taken from the Perl documentation.
1022    The numbers underneath show in which buffer the captured content will be
1023    stored.
1024    .sp
1025      # before  ---------------branch-reset----------- after
1026      / ( a )  (?| x ( y ) z | (p (q) r) | (t) u (v) ) ( z ) /x
1027      # 1            2         2  3        2     3     4
1028    .sp
1029    A backreference or a recursive call to a numbered subpattern always refers to
1030    the first one in the pattern with the given number.
1031    .P
1032    An alternative approach to using this "branch reset" feature is to use
1033    duplicate named subpatterns, as described in the next section.
1034    .
1035    .
1036  .SH "NAMED SUBPATTERNS"  .SH "NAMED SUBPATTERNS"
1037  .rs  .rs
1038  .sp  .sp
# Line 1007  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"
1086    subpattern, as described in the previous section.)
1087    .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
1089  for the first (and in this example, the only) subpattern of that name that  for the first (and in this example, the only) subpattern of that name that
1090  matched. This saves searching to find which numbered subpattern it was. If you  matched. This saves searching to find which numbered subpattern it was. If you
# Line 1898  Cambridge CB2 3QH, England. Line 1976  Cambridge CB2 3QH, England.
1976  .rs  .rs
1977  .sp  .sp
1978  .nf  .nf
1979  Last updated: 29 May 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.172  
changed lines
  Added in v.185

  ViewVC Help
Powered by ViewVC 1.1.5