--- code/trunk/doc/html/pcre.html 2007/02/24 21:41:21 87 +++ code/trunk/doc/html/pcre.html 2007/08/06 15:23:29 208 @@ -18,18 +18,24 @@
  • LIMITATIONS
  • UTF-8 AND UNICODE PROPERTY SUPPORT
  • AUTHOR +
  • REVISION
    INTRODUCTION

    The PCRE library is a set of functions that implement regular expression pattern matching using the same syntax and semantics as Perl, with just a few -differences. The current implementation of PCRE (release 6.x) corresponds -approximately with Perl 5.8, including support for UTF-8 encoded strings and -Unicode general category properties. However, this support has to be explicitly -enabled; it is not the default. +differences. (Certain features that appeared in Python and PCRE before they +appeared in Perl are also available using the Python syntax.)

    -In addition to the Perl-compatible matching function, PCRE also contains an +The current implementation of PCRE (release 7.x) corresponds approximately with +Perl 5.10, including support for UTF-8 encoded strings and Unicode general +category properties. However, UTF-8 and Unicode support has to be explicitly +enabled; it is not the default. The Unicode tables correspond to Unicode +release 5.0.0. +

    +

    +In addition to the Perl-compatible matching function, PCRE contains an alternative matching function that matches the same compiled patterns in a different way. In certain circumstances, the alternative function has some advantages. For a discussion of the two matching algorithms, see the @@ -52,7 +58,9 @@ pcrepattern and pcrecompat -pages. +pages. There is a syntax summary in the +pcresyntax +page.

    Some features of PCRE can be included, excluded, or changed when the library is @@ -82,6 +90,7 @@ follows:

       pcre              this document
    +  pcre-config       show PCRE installation configuration information
       pcreapi           details of PCRE's native C API
       pcrebuild         options for building PCRE
       pcrecallout       details of the callout feature
    @@ -91,10 +100,12 @@
       pcrematching      discussion of the two matching algorithms
       pcrepartial       details of the partial matching facility
       pcrepattern       syntax and semantics of supported regular expressions
    +  pcresyntax        quick syntax reference
       pcreperform       discussion of performance issues
       pcreposix         the POSIX-compatible C API
       pcreprecompile    details of saving and re-using precompiled patterns
       pcresample        discussion of the sample program
    +  pcrestack         discussion of stack usage
       pcretest          description of the pcretest testing command
     
    In addition, in the "man" and HTML formats, there is a short page for each @@ -113,23 +124,28 @@ distribution and the pcrebuild documentation for details). In these cases the limit is substantially larger. -However, the speed of execution will be slower. +However, the speed of execution is slower.

    All values in repeating quantifiers must be less than 65536. -The maximum number of capturing subpatterns is 65535.

    -There is no limit to the number of non-capturing subpatterns, but the maximum -depth of nesting of all kinds of parenthesized subpattern, including capturing -subpatterns, assertions, and other types of subpattern, is 200. +There is no limit to the number of parenthesized subpatterns, but there can be +no more than 65535 capturing subpatterns. +

    +

    +The maximum length of name for a named subpattern is 32 characters, and the +maximum number of named subpatterns is 10000.

    The maximum length of a subject string is the largest positive number that an integer variable can hold. However, when using the traditional matching function, PCRE uses recursion to handle subpatterns and indefinite repetition. This means that the available stack space may limit the size of a subject -string that can be processed by certain patterns. +string that can be processed by certain patterns. For a discussion of stack +issues, see the +pcrestack +documentation.


    UTF-8 AND UNICODE PROPERTY SUPPORT

    @@ -149,7 +165,7 @@

    If you compile PCRE with UTF-8 support, but do not use it at run time, the library will be a bit bigger, but the additional run time overhead is limited -to testing the PCRE_UTF8 flag in several places, so should not be very large. +to testing the PCRE_UTF8 flag occasionally, so should not be very big.

    If PCRE is built with Unicode character property support (which implies UTF-8 @@ -184,19 +200,23 @@ UTF-8 character if the value is greater than 127.

    -3. Repeat quantifiers apply to complete UTF-8 characters, not to individual +3. Octal numbers up to \777 are recognized, and match two-byte UTF-8 +characters for values greater than \177. +

    +

    +4. Repeat quantifiers apply to complete UTF-8 characters, not to individual bytes, for example: \x{100}{3}.

    -4. The dot metacharacter matches one UTF-8 character instead of a single byte. +5. The dot metacharacter matches one UTF-8 character instead of a single byte.

    -5. The escape sequence \C can be used to match a single byte in UTF-8 mode, +6. The escape sequence \C can be used to match a single byte in UTF-8 mode, but its use can lead to some strange effects. This facility is not available in the alternative matching function, pcre_dfa_exec().

    -6. The character escapes \b, \B, \d, \D, \s, \S, \w, and \W correctly +7. The character escapes \b, \B, \d, \D, \s, \S, \w, and \W correctly test characters of any code value, but the characters that PCRE recognizes as digits, spaces, or word characters remain the same set as before, all with values less than 256. This remains true even when PCRE includes Unicode @@ -205,11 +225,15 @@ must use Unicode property tests such as \p{Nd}.

    -7. Similarly, characters that match the POSIX named character classes are all +8. Similarly, characters that match the POSIX named character classes are all low-valued characters.

    -8. Case-insensitive matching applies only to characters whose values are less +9. However, the Perl 5.10 horizontal and vertical whitespace matching escapes +(\h, \H, \v, and \V) do match all the appropriate Unicode characters. +

    +

    +10. Case-insensitive matching applies only to characters whose values are less than 128, unless PCRE is built with Unicode property support. Even when Unicode property support is available, PCRE still uses its own character tables when checking the case of low-valued characters, so as not to degrade performance. @@ -223,17 +247,22 @@

    Philip Hazel
    -University Computing Service, +University Computing Service +
    +Cambridge CB2 3QH, England.
    -Cambridge CB2 3QG, England.

    Putting an actual email address here seems to have been a spam magnet, so I've -taken it away. If you want to email me, use my initial and surname, separated -by a dot, at the domain ucs.cam.ac.uk. -Last updated: 24 January 2006 +taken it away. If you want to email me, use my two initials, followed by the +two digits 10, at the domain cam.ac.uk. +

    +
    REVISION
    +

    +Last updated: 06 August 2007 +
    +Copyright © 1997-2007 University of Cambridge.
    -Copyright © 1997-2006 University of Cambridge.

    Return to the PCRE index page.