diff --git a/doc/html/boost_regex/background_information/examples.html b/doc/html/boost_regex/background_information/examples.html index 99b7fbc6..b5d3b485 100644 --- a/doc/html/boost_regex/background_information/examples.html +++ b/doc/html/boost_regex/background_information/examples.html @@ -28,7 +28,7 @@ Example Programs
- + Test Programs
@@ -107,7 +107,7 @@ Files: captures_test.cpp.

- + Example programs
@@ -133,7 +133,7 @@ Files: regex_timer.cpp.

- + Code snippets
diff --git a/doc/html/boost_regex/background_information/history.html b/doc/html/boost_regex/background_information/history.html index 601b75e1..f42f7bff 100644 --- a/doc/html/boost_regex/background_information/history.html +++ b/doc/html/boost_regex/background_information/history.html @@ -26,7 +26,7 @@ History
- + Boost 1.38
@@ -53,7 +53,7 @@
- + Boost 1.34
@@ -76,7 +76,7 @@
- + Boost 1.33.1
@@ -146,7 +146,7 @@
- + Boost 1.33.0
@@ -201,7 +201,7 @@
- + Boost 1.32.1
@@ -209,7 +209,7 @@ Fixed bug in partial matches of bounded repeats of '.'.
- + Boost 1.31.0
diff --git a/doc/html/boost_regex/background_information/locale.html b/doc/html/boost_regex/background_information/locale.html index 79434fe7..62284e82 100644 --- a/doc/html/boost_regex/background_information/locale.html +++ b/doc/html/boost_regex/background_information/locale.html @@ -58,7 +58,7 @@ There are three separate localization mechanisms supported by Boost.Regex:

- + Win32 localization model.
@@ -90,7 +90,7 @@ are treated as "unknown" graphic characters.

- + C localization model.
@@ -114,7 +114,7 @@ libraries including version 1 of this library.

- + C++ localization model.
@@ -151,7 +151,7 @@ in your code. The best way to ensure this is to add the #define to <boost/regex/user.hpp>.

- + Providing a message catalogue
diff --git a/doc/html/boost_regex/background_information/standards.html b/doc/html/boost_regex/background_information/standards.html index b27a8940..437e53e0 100644 --- a/doc/html/boost_regex/background_information/standards.html +++ b/doc/html/boost_regex/background_information/standards.html @@ -28,7 +28,7 @@ Conformance
- + C++

@@ -36,7 +36,7 @@ Report on C++ Library Extensions.

- + ECMAScript / JavaScript
@@ -49,7 +49,7 @@ rather than a Unicode escape sequence; use \x{DDDD} for Unicode escape sequences.

- + Perl

@@ -62,7 +62,7 @@ (??{code}) Not implementable in a compiled strongly typed language.

- + POSIX

@@ -82,7 +82,7 @@ a custom traits class.

- + Unicode

diff --git a/doc/html/boost_regex/captures.html b/doc/html/boost_regex/captures.html index 7ebc73c3..c4dcc347 100644 --- a/doc/html/boost_regex/captures.html +++ b/doc/html/boost_regex/captures.html @@ -35,7 +35,7 @@ accessed.

- + Marked sub-expressions

@@ -218,7 +218,7 @@ output stream.

- + Unmatched Sub-Expressions

@@ -231,7 +231,7 @@ you can determine which sub-expressions matched by accessing the sub_match::matched data member.

- + Repeated Captures

diff --git a/doc/html/boost_regex/format/boost_format_syntax.html b/doc/html/boost_regex/format/boost_format_syntax.html index 12dd9109..809f2205 100644 --- a/doc/html/boost_regex/format/boost_format_syntax.html +++ b/doc/html/boost_regex/format/boost_format_syntax.html @@ -32,7 +32,7 @@ '$', '\', '(', ')', '?', and ':'.

- + Grouping

@@ -40,7 +40,7 @@ you want a to output literal parenthesis.

- + Conditionals

@@ -66,7 +66,7 @@ with "bar" otherwise.

- + Placeholder Sequences
@@ -161,7 +161,7 @@ as a literal.

- + Escape Sequences
diff --git a/doc/html/boost_regex/install.html b/doc/html/boost_regex/install.html index 99b298f5..05d2a54d 100644 --- a/doc/html/boost_regex/install.html +++ b/doc/html/boost_regex/install.html @@ -49,7 +49,7 @@ file before you can use it, instructions for specific platforms are as follows:

- + Building with bjam

@@ -58,7 +58,7 @@ started guide for more information.

- + Building With Unicode and ICU Support
@@ -96,11 +96,11 @@ ICU you are using is binary compatible with the toolset you use to build Boost.

- + Building via makefiles
- + Borland C++ Builder:
- + GCC(2.95 and later)

@@ -302,7 +302,7 @@ see the config library documentation.

- + Sun Workshop 6.1

@@ -347,7 +347,7 @@ will build v9 variants of the regex library named libboost_regex_v9.a etc.

- + Makefiles for Other compilers
diff --git a/doc/html/boost_regex/ref/bad_expression.html b/doc/html/boost_regex/ref/bad_expression.html index f78ef075..1d079e4f 100644 --- a/doc/html/boost_regex/ref/bad_expression.html +++ b/doc/html/boost_regex/ref/bad_expression.html @@ -27,7 +27,7 @@ bad_expression
- + Synopsis
#include <boost/pattern_except.hpp>
@@ -54,7 +54,7 @@
 } // namespace boost
 
- + Description
regex_error(const std::string& s, regex_constants::error_type err, std::ptrdiff_t pos);
diff --git a/doc/html/boost_regex/ref/basic_regex.html b/doc/html/boost_regex/ref/basic_regex.html
index 30cb5969..a0c13601 100644
--- a/doc/html/boost_regex/ref/basic_regex.html
+++ b/doc/html/boost_regex/ref/basic_regex.html
@@ -27,7 +27,7 @@
  basic_regex
 
 
- + Synopsis
#include <boost/regex.hpp>
@@ -244,7 +244,7 @@
 } // namespace boost
 
- + Description

@@ -327,7 +327,7 @@ basic_regex.

-

Table 1. basic_regex default construction postconditions

+

Table 1. basic_regex default construction postconditions

@@ -407,7 +407,7 @@ flags specified in f.

-

Table 2. Postconditions for basic_regex construction

+

Table 2. Postconditions for basic_regex construction

@@ -512,7 +512,7 @@ specified in f.

-

Table 3. Postconditions for basic_regex construction

+

Table 3. Postconditions for basic_regex construction

@@ -616,7 +616,7 @@ according the option flags specified in f.

-

Table 4. Postconditions for basic_regex construction

+

Table 4. Postconditions for basic_regex construction

@@ -727,7 +727,7 @@ flags specified in f.

-

Table 5. Postconditions for basic_regex construction

+

Table 5. Postconditions for basic_regex construction

@@ -829,7 +829,7 @@ flags specified in f.

-

Table 6. Postconditions for basic_regex construction

+

Table 6. Postconditions for basic_regex construction

@@ -1043,7 +1043,7 @@ in f.

-

Table 7. Postconditions for basic_regex::assign

+

Table 7. Postconditions for basic_regex::assign

diff --git a/doc/html/boost_regex/ref/concepts/traits_concept.html b/doc/html/boost_regex/ref/concepts/traits_concept.html index ad23e706..fe4b0274 100644 --- a/doc/html/boost_regex/ref/concepts/traits_concept.html +++ b/doc/html/boost_regex/ref/concepts/traits_concept.html @@ -34,7 +34,7 @@ Boost-specific enhanced interface.

- + Minimal requirements.
@@ -381,7 +381,7 @@
- + Additional Optional Requirements
diff --git a/doc/html/boost_regex/ref/deprecated_interfaces/regex_format.html b/doc/html/boost_regex/ref/deprecated_interfaces/regex_format.html index 02829968..70fae8b1 100644 --- a/doc/html/boost_regex/ref/deprecated_interfaces/regex_format.html +++ b/doc/html/boost_regex/ref/deprecated_interfaces/regex_format.html @@ -34,7 +34,7 @@ previous version of Boost.Regex and will not be further updated:

- + Algorithm regex_format
diff --git a/doc/html/boost_regex/ref/error_type.html b/doc/html/boost_regex/ref/error_type.html index baa2636a..7fb8bbe7 100644 --- a/doc/html/boost_regex/ref/error_type.html +++ b/doc/html/boost_regex/ref/error_type.html @@ -27,7 +27,7 @@ error_type
- + Synopsis

@@ -57,7 +57,7 @@ } // namespace boost

- + Description

diff --git a/doc/html/boost_regex/ref/match_flag_type.html b/doc/html/boost_regex/ref/match_flag_type.html index 8ee8482a..dfbdfdc1 100644 --- a/doc/html/boost_regex/ref/match_flag_type.html +++ b/doc/html/boost_regex/ref/match_flag_type.html @@ -69,7 +69,7 @@ } // namespace boost

- + Description

diff --git a/doc/html/boost_regex/ref/match_results.html b/doc/html/boost_regex/ref/match_results.html index 94438118..7961ad1e 100644 --- a/doc/html/boost_regex/ref/match_results.html +++ b/doc/html/boost_regex/ref/match_results.html @@ -27,7 +27,7 @@ match_results

- + Synopsis
#include <boost/regex.hpp>
@@ -142,7 +142,7 @@
          match_results<BidirectionalIterator, Allocator>& m2);
 
- + Description

diff --git a/doc/html/boost_regex/ref/non_std_strings/icu/unicode_algo.html b/doc/html/boost_regex/ref/non_std_strings/icu/unicode_algo.html index ca7dd081..f7379cd2 100644 --- a/doc/html/boost_regex/ref/non_std_strings/icu/unicode_algo.html +++ b/doc/html/boost_regex/ref/non_std_strings/icu/unicode_algo.html @@ -43,7 +43,7 @@ on to the "real" algorithm.

- + u32regex_match

@@ -89,7 +89,7 @@ }

- + u32regex_search

@@ -128,7 +128,7 @@ }

- + u32regex_replace

diff --git a/doc/html/boost_regex/ref/non_std_strings/icu/unicode_iter.html b/doc/html/boost_regex/ref/non_std_strings/icu/unicode_iter.html index be77c195..6f432bd3 100644 --- a/doc/html/boost_regex/ref/non_std_strings/icu/unicode_iter.html +++ b/doc/html/boost_regex/ref/non_std_strings/icu/unicode_iter.html @@ -28,7 +28,7 @@ Unicode Aware Regex Iterators

- + u32regex_iterator

@@ -126,7 +126,7 @@ Provided of course that the input is encoded as UTF-8.

- + u32regex_token_iterator

diff --git a/doc/html/boost_regex/ref/non_std_strings/mfc_strings/mfc_algo.html b/doc/html/boost_regex/ref/non_std_strings/mfc_strings/mfc_algo.html index 7bb1c915..49195299 100644 --- a/doc/html/boost_regex/ref/non_std_strings/mfc_strings/mfc_algo.html +++ b/doc/html/boost_regex/ref/non_std_strings/mfc_strings/mfc_algo.html @@ -34,7 +34,7 @@ here they are anyway:

- + regex_match

@@ -82,7 +82,7 @@ }

- + regex_match (second overload)
@@ -110,7 +110,7 @@ }
- + regex_search

@@ -149,7 +149,7 @@ }

- + regex_search (second overload)
@@ -164,7 +164,7 @@ + s.GetLength(), e, f);

- + regex_replace

diff --git a/doc/html/boost_regex/ref/non_std_strings/mfc_strings/mfc_iter.html b/doc/html/boost_regex/ref/non_std_strings/mfc_strings/mfc_iter.html index a6c18255..8286c553 100644 --- a/doc/html/boost_regex/ref/non_std_strings/mfc_strings/mfc_iter.html +++ b/doc/html/boost_regex/ref/non_std_strings/mfc_strings/mfc_iter.html @@ -32,7 +32,7 @@ an MFC/ATL string to a regex_iterator or regex_token_iterator:

- + regex_iterator creation helper
@@ -68,7 +68,7 @@ }
- + regex_token_iterator creation helpers
diff --git a/doc/html/boost_regex/ref/posix.html b/doc/html/boost_regex/ref/posix.html index f9b28b98..44ead2e9 100644 --- a/doc/html/boost_regex/ref/posix.html +++ b/doc/html/boost_regex/ref/posix.html @@ -165,7 +165,7 @@

- + regcomp

@@ -379,7 +379,7 @@

- + regerror

@@ -467,7 +467,7 @@

- + regexec

@@ -537,7 +537,7 @@

- + regfree

diff --git a/doc/html/boost_regex/ref/regex_iterator.html b/doc/html/boost_regex/ref/regex_iterator.html index a3c9d35c..ba71a9af 100644 --- a/doc/html/boost_regex/ref/regex_iterator.html +++ b/doc/html/boost_regex/ref/regex_iterator.html @@ -78,7 +78,7 @@ regex_constants::match_flag_type m = regex_constants::match_default);

- + Description

@@ -436,7 +436,7 @@ m.

- + Examples

diff --git a/doc/html/boost_regex/ref/regex_match.html b/doc/html/boost_regex/ref/regex_match.html index 72e113b4..5ce57f3c 100644 --- a/doc/html/boost_regex/ref/regex_match.html +++ b/doc/html/boost_regex/ref/regex_match.html @@ -80,7 +80,7 @@ match_flag_type flags = match_default);

- + Description
template <class BidirectionalIterator, class Allocator, class charT, class traits>
@@ -360,7 +360,7 @@
         Effects: Returns the result of regex_match(s.begin(), s.end(), e, flags).
       

- + Examples

diff --git a/doc/html/boost_regex/ref/regex_replace.html b/doc/html/boost_regex/ref/regex_replace.html index 72e84c91..f25d7aab 100644 --- a/doc/html/boost_regex/ref/regex_replace.html +++ b/doc/html/boost_regex/ref/regex_replace.html @@ -53,7 +53,7 @@ match_flag_type flags = match_default);

- + Description
template <class OutputIterator, class BidirectionalIterator, class traits, class charT>
@@ -163,7 +163,7 @@
         and then returns result.
       

- + Examples

diff --git a/doc/html/boost_regex/ref/regex_search.html b/doc/html/boost_regex/ref/regex_search.html index 8c10b0ec..cefe95b9 100644 --- a/doc/html/boost_regex/ref/regex_search.html +++ b/doc/html/boost_regex/ref/regex_search.html @@ -73,7 +73,7 @@ match_flag_type flags = match_default);

- + Description
template <class BidirectionalIterator, class Allocator, class charT, class traits>
@@ -355,7 +355,7 @@
         Effects: Returns the result of regex_search(s.begin(), s.end(), e, flags).
       

- + Examples

diff --git a/doc/html/boost_regex/ref/regex_token_iterator.html b/doc/html/boost_regex/ref/regex_token_iterator.html index 14dedba1..fbd5e0e5 100644 --- a/doc/html/boost_regex/ref/regex_token_iterator.html +++ b/doc/html/boost_regex/ref/regex_token_iterator.html @@ -136,7 +136,7 @@ regex_constants::match_flag_type m = regex_constants::match_default);

- + Description

@@ -383,7 +383,7 @@ m.

- + Examples

diff --git a/doc/html/boost_regex/ref/regex_traits.html b/doc/html/boost_regex/ref/regex_traits.html index 04a84d31..16ac10d0 100644 --- a/doc/html/boost_regex/ref/regex_traits.html +++ b/doc/html/boost_regex/ref/regex_traits.html @@ -46,7 +46,7 @@ } // namespace boost

- + Description

diff --git a/doc/html/boost_regex/ref/sub_match.html b/doc/html/boost_regex/ref/sub_match.html index 98bd6f93..18629564 100644 --- a/doc/html/boost_regex/ref/sub_match.html +++ b/doc/html/boost_regex/ref/sub_match.html @@ -329,11 +329,11 @@ } // namespace boost

- + Description
- + Members

@@ -473,7 +473,7 @@

- + sub_match non-member operators
@@ -1008,7 +1008,7 @@ + m2.str().

- + Stream inserter

diff --git a/doc/html/boost_regex/syntax/basic_extended.html b/doc/html/boost_regex/syntax/basic_extended.html index d970baf0..6f13adaa 100644 --- a/doc/html/boost_regex/syntax/basic_extended.html +++ b/doc/html/boost_regex/syntax/basic_extended.html @@ -28,7 +28,7 @@ Expression Syntax

- + Synopsis

@@ -46,7 +46,7 @@

- + POSIX Extended Syntax

@@ -56,7 +56,7 @@

.[{()\*+?|^$
- + Wildcard:

@@ -74,7 +74,7 @@

- + Anchors:

@@ -86,7 +86,7 @@ of an expression, or the last character of a sub-expression.

- + Marked sub-expressions:
@@ -98,7 +98,7 @@ to by a back-reference.

- + Repeats:

@@ -184,7 +184,7 @@ cab operator to be applied to.

- + Back references:

@@ -214,7 +214,7 @@ cab

- + Alternation

@@ -227,7 +227,7 @@ cab will match either of "abd" or "abef".

- + Character sets:
@@ -240,7 +240,7 @@ cab A bracket expression may contain any combination of the following:

- + Single characters:
@@ -249,7 +249,7 @@ cab or 'c'.

- + Character ranges:
@@ -265,7 +265,7 @@ cab the code points of the characters only.

- + Negation:

@@ -274,7 +274,7 @@ cab range a-c.

- + Character classes:
@@ -284,7 +284,7 @@ cab character class names.

- + Collating Elements:
@@ -312,7 +312,7 @@ cab matches a NUL character.

- + Equivalence classes:
@@ -329,7 +329,7 @@ cab or even all locales on one platform.

- + Combinations:

@@ -337,7 +337,7 @@ cab [[:digit:]a-c[.NUL.]].

- + Escapes

@@ -363,7 +363,7 @@ cab extensions are also supported by Boost.Regex:

- + Escapes matching a specific character
@@ -552,7 +552,7 @@ cab
- + "Single character" character classes:
@@ -706,7 +706,7 @@ cab
- + Character Properties
@@ -813,7 +813,7 @@ cab matches any "digit" character, as does \p{digit}.

- + Word Boundaries

@@ -888,7 +888,7 @@ cab

- + Buffer boundaries
@@ -979,7 +979,7 @@ cab
- + Continuation Escape
@@ -991,7 +991,7 @@ cab match to start where the last one ended.

- + Quoting escape
@@ -1005,7 +1005,7 @@ cab \*+aaa
- + Unicode escapes
@@ -1056,7 +1056,7 @@ cab
- + Any other escape
@@ -1065,7 +1065,7 @@ cab \@ matches a literal '@'.

- + Operator precedence
@@ -1101,7 +1101,7 @@ cab
- + What Gets Matched
@@ -1111,11 +1111,11 @@ cab rule.

- + Variations

- + Egrep

@@ -1136,7 +1136,7 @@ cab used with the -E option.

- + awk

@@ -1150,7 +1150,7 @@ cab these by default anyway.

- + Options

@@ -1163,7 +1163,7 @@ cab modify how the case and locale sensitivity are to be applied.

- + References

diff --git a/doc/html/boost_regex/syntax/basic_syntax.html b/doc/html/boost_regex/syntax/basic_syntax.html index 72f216b8..8de6b127 100644 --- a/doc/html/boost_regex/syntax/basic_syntax.html +++ b/doc/html/boost_regex/syntax/basic_syntax.html @@ -28,7 +28,7 @@ Expression Syntax

- + Synopsis

@@ -45,7 +45,7 @@

- + POSIX Basic Syntax

@@ -55,7 +55,7 @@

.[\*^$
- + Wildcard:

@@ -73,7 +73,7 @@

- + Anchors:

@@ -85,7 +85,7 @@ of an expression, or the last character of a sub-expression.

- + Marked sub-expressions:
@@ -97,7 +97,7 @@ by a back-reference.

- + Repeats:

@@ -155,7 +155,7 @@ aaaa to.

- + Back references:

@@ -173,7 +173,7 @@ aaaa

aaabba
- + Character sets:
@@ -186,7 +186,7 @@ aaaa A bracket expression may contain any combination of the following:

- + Single characters:
@@ -195,7 +195,7 @@ aaaa or 'c'.

- + Character ranges:
@@ -211,7 +211,7 @@ aaaa of the characters only.

- + Negation:

@@ -220,7 +220,7 @@ aaaa range a-c.

- + Character classes:
@@ -230,7 +230,7 @@ aaaa character class names.

- + Collating Elements:
@@ -259,7 +259,7 @@ aaaa element names.

- + Equivalence classes:
@@ -276,7 +276,7 @@ aaaa or even all locales on one platform.

- + Combinations:

@@ -284,7 +284,7 @@ aaaa [[:digit:]a-c[.NUL.]].

- + Escapes

@@ -299,7 +299,7 @@ aaaa will match either a literal '\' or a '^'.

- + What Gets Matched

@@ -309,13 +309,13 @@ aaaa rule.

- + Variations

- + Grep

@@ -333,7 +333,7 @@ aaaa As its name suggests, this behavior is consistent with the Unix utility grep.

- + emacs

@@ -613,7 +613,7 @@ aaaa leftmost-longest rule.

- + Options

@@ -627,7 +627,7 @@ aaaa options modify how the case and locale sensitivity are to be applied.

- + References

diff --git a/doc/html/boost_regex/syntax/perl_syntax.html b/doc/html/boost_regex/syntax/perl_syntax.html index 88b5fdb0..c97738cf 100644 --- a/doc/html/boost_regex/syntax/perl_syntax.html +++ b/doc/html/boost_regex/syntax/perl_syntax.html @@ -28,15 +28,13 @@ Syntax

- + Synopsis

The Perl regular expression syntax is based on that used by the programming language Perl . Perl regular expressions are the default behavior in Boost.Regex - or you can pass the flag perl - to the basic_regex - constructor, for example: + or you can pass the flag perl to the basic_regex constructor, for example:

// e1 is a case sensitive Perl regular expression: 
 // since Perl is the default option there's no need to explicitly specify the syntax used here:
@@ -45,7 +43,7 @@
 boost::regex e2(my_expression, boost::regex::perl|boost::regex::icase);
 

- + Perl Regular Expression Syntax

@@ -55,7 +53,7 @@

.[{()\*+?|^$
- + Wildcard

@@ -65,17 +63,17 @@

- + Anchors

@@ -85,19 +83,18 @@ A '$' character shall match the end of a line.

- + Marked sub-expressions

- A section beginning ( and ending - ) acts as a marked sub-expression. - Whatever matched the sub-expression is split out in a separate field by the - matching algorithms. Marked sub-expressions can also repeated, or referred - to by a back-reference. + A section beginning ( and ending ) + acts as a marked sub-expression. Whatever matched the sub-expression is split + out in a separate field by the matching algorithms. Marked sub-expressions + can also repeated, or referred to by a back-reference.

- + Non-marking grouping
@@ -105,34 +102,32 @@ A marked sub-expression is useful to lexically group part of a regular expression, but has the side-effect of spitting out an extra field in the result. As an alternative you can lexically group part of a regular expression, without - generating a marked sub-expression by using (?: - and ) , for example (?:ab)+ - will repeat ab without splitting - out any separate sub-expressions. + generating a marked sub-expression by using (?: and ) + , for example (?:ab)+ will repeat ab + without splitting out any separate sub-expressions.

- + Repeats

Any atom (a single character, a marked sub-expression, or a character class) - can be repeated with the *, - +, ?, - and {} operators. + can be repeated with the *, +, ?, + and {} operators.

- The * operator will match the - preceding atom zero or more times, for example the expression a*b - will match any of the following: + The * operator will match the preceding atom zero or more + times, for example the expression a*b will match any of + the following:

b
 ab
 aaaaaaaab
 

- The + operator will match the - preceding atom one or more times, for example the expression a+b - will match any of the following: + The + operator will match the preceding atom one or more + times, for example the expression a+b will match any of + the following:

ab
 aaaaaaaab
@@ -143,9 +138,8 @@
 
b
 

- The ? operator will match the - preceding atom zero or one times, for example the expression ca?b will match - any of the following: + The ? operator will match the preceding atom zero or one + times, for example the expression ca?b will match any of the following:

cb
 cab
@@ -159,16 +153,13 @@
         An atom can also be repeated with a bounded repeat:
       

- a{n} Matches - 'a' repeated exactly n times. + a{n} Matches 'a' repeated exactly n times.

- a{n,} Matches - 'a' repeated n or more times. + a{n,} Matches 'a' repeated n or more times.

- a{n, m} Matches 'a' repeated between n and m times - inclusive. + a{n, m} Matches 'a' repeated between n and m times inclusive.

For example: @@ -193,11 +184,11 @@

a(*)
 

- Will raise an error, as there is nothing for the * - operator to be applied to. + Will raise an error, as there is nothing for the * operator + to be applied to.

- + Non greedy repeats
@@ -207,28 +198,27 @@ that will consume as little input as possible while still producing a match.

- *? Matches the previous atom - zero or more times, while consuming as little input as possible. + *? Matches the previous atom zero or more times, while + consuming as little input as possible.

- +? Matches the previous atom - one or more times, while consuming as little input as possible. + +? Matches the previous atom one or more times, while + consuming as little input as possible.

- ?? Matches the previous atom - zero or one times, while consuming as little input as possible. + ?? Matches the previous atom zero or one times, while + consuming as little input as possible.

- {n,}? Matches the previous atom n or more times, + {n,}? Matches the previous atom n or more times, while + consuming as little input as possible. +

+

+ {n,m}? Matches the previous atom between n and m times, while consuming as little input as possible.

-

- {n,m}? - Matches the previous atom between n and m times, while consuming as little - input as possible. -

- + Pocessive repeats
@@ -240,27 +230,27 @@ match.

- *+ Matches the previous atom - zero or more times, while giving nothing back. + *+ Matches the previous atom zero or more times, while + giving nothing back.

- ++ Matches the previous atom - one or more times, while giving nothing back. + ++ Matches the previous atom one or more times, while + giving nothing back.

- ?+ Matches the previous atom - zero or one times, while giving nothing back. + ?+ Matches the previous atom zero or one times, while + giving nothing back.

- {n,}+ Matches the previous atom n or more times, + {n,}+ Matches the previous atom n or more times, while + giving nothing back. +

+

+ {n,m}+ Matches the previous atom between n and m times, while giving nothing back.

-

- {n,m}+ - Matches the previous atom between n and m times, while giving nothing back. -

- + Back references

@@ -279,99 +269,170 @@

aaabba
 
+

+ You can also use the \g escape for the same function, for example: +

+
++++ + + + + + + + + + + + + + + + + + + + + + + +
+

+ Escape +

+
+

+ Meaning +

+
+

+ \g1 +

+
+

+ Match whatever matched sub-expression 1 +

+
+

+ \g{1} +

+
+

+ Match whatever matched sub-expression 1: this form allows for safer + parsing of the expression in cases like \g{1}2 + or for indexes higher than 9 as in \g{1234} +

+
+

+ \g-1 +

+
+

+ Match whatever matched the last opened sub-expression +

+
+

+ \g{-2} +

+
+

+ Match whatever matched the last but one opened sub-expression +

+
- + Alternation

- The | operator will match either - of its arguments, so for example: abc|def will - match either "abc" or "def". + The | operator will match either of its arguments, so + for example: abc|def will match either "abc" + or "def".

- Parenthesis can be used to group alternations, for example: ab(d|ef) + Parenthesis can be used to group alternations, for example: ab(d|ef) will match either of "abd" or "abef".

Empty alternatives are not allowed (these are almost always a mistake), but - if you really want an empty alternative use (?:) - as a placeholder, for example: + if you really want an empty alternative use (?:) as a + placeholder, for example:

- |abc - is not a valid expression, but + |abc is not a valid expression, but

- (?:)|abc - is and is equivalent, also the expression: + (?:)|abc is and is equivalent, also the expression:

- (?:abc)?? has exactly the same effect. + (?:abc)?? has exactly the same effect.

- + Character sets

- A character set is a bracket-expression starting with [ - and ending with ], it defines - a set of characters, and matches any single character that is a member of - that set. + A character set is a bracket-expression starting with [ + and ending with ], it defines a set of characters, and + matches any single character that is a member of that set.

A bracket expression may contain any combination of the following:

- + Single characters

- For example [abc], will match any of the characters 'a', 'b', - or 'c'. + For example [abc], will match any of the characters 'a', + 'b', or 'c'.

- + Character ranges

- For example [a-c] - will match any single character in the range 'a' to 'c'. By default, for - Perl regular expressions, a character x is within the range y to z, if the - code point of the character lies within the codepoints of the endpoints of - the range. Alternatively, if you set the collate flag when constructing the - regular expression, then ranges are locale sensitive. + For example [a-c] will match any single character in the + range 'a' to 'c'. By default, for Perl regular expressions, a character x + is within the range y to z, if the code point of the character lies within + the codepoints of the endpoints of the range. Alternatively, if you set the + collate + flag when constructing the regular expression, then ranges are locale + sensitive.

- + Negation

If the bracket-expression begins with the ^ character, then it matches the - complement of the characters it contains, for example [^a-c] matches any character that is not in the - range a-c. + complement of the characters it contains, for example [^a-c] + matches any character that is not in the range a-c.

- + Character classes

- An expression of the form [[:name:]] - matches the named character class "name", for example [[:lower:]] matches any lower case character. See - character class names. + An expression of the form [[:name:]] matches the named + character class "name", for example [[:lower:]] + matches any lower case character. See character + class names.

- + Collating Elements

- An expression of the form [[.col.] matches - the collating element col. A collating element is any - single character, or any sequence of characters that collates as a single - unit. Collating elements may also be used as the end point of a range, for - example: [[.ae.]-c] + An expression of the form [[.col.]] matches the collating + element col. A collating element is any single character, + or any sequence of characters that collates as a single unit. Collating elements + may also be used as the end point of a range, for example: [[.ae.]-c] matches the character sequence "ae", plus any single character in the range "ae"-c, assuming that "ae" is treated as a single collating element in the current locale. @@ -382,28 +443,27 @@

[[.NUL.]]
 

- matches a \0 - character. + matches a \0 character.

- + Equivalence classes

- An expression of the form [[=col=]], - matches any character or collating element whose primary sort key is the - same as that for collating element col, as with collating - elements the name col may be a symbolic - name. A primary sort key is one that ignores case, accentation, or - locale-specific tailorings; so for example [[=a=]] matches + An expression of the form [[=col=]], matches any character + or collating element whose primary sort key is the same as that for collating + element col, as with collating elements the name col + may be a symbolic name. + A primary sort key is one that ignores case, accentation, or locale-specific + tailorings; so for example [[=a=]] matches any of the characters: a, À, Á, Â, Ã, Ä, Å, A, à, á, â, ã, ä and å. Unfortunately implementation of this is reliant on the platform's collation and localisation support; this feature can not be relied upon to work portably across all platforms, or even all locales on one platform.

- + Escaped Characters
@@ -415,15 +475,15 @@ is not a "word" character.

- + Combinations

All of the above can be combined in one character set declaration, for example: - [[:digit:]a-c[.NUL.]]. + [[:digit:]a-c[.NUL.]].

- + Escapes

@@ -453,105 +513,103 @@

- \a + \a

- \a + \a

- \e + \e

- 0x1B + 0x1B

- \f + \f

- \f + \f

- \n + \n

- \n + \n

- \r + \r

- \r + \r

- \t + \t

- \t + \t

- \v - + \v

- \v + \v

- \b + \b

- \b - (but only inside a character class declaration). + \b (but only inside a character class declaration).

- \cX + \cX

@@ -564,7 +622,7 @@

- \xdd + \xdd

@@ -577,7 +635,7 @@

- \x{dddd} + \x{dddd}

@@ -590,7 +648,7 @@

- \0ddd + \0ddd

@@ -603,20 +661,21 @@

- \N{name} + \N{name}

Matches the single character which has the symbolic - name name. For example \N{newline} matches the single character \n. + name name. For example \N{newline} + matches the single character \n.

- + "Single character" character classes:
@@ -818,7 +877,7 @@
- + Character Properties
@@ -922,33 +981,30 @@

- For example \pd - matches any "digit" character, as does \p{digit}. + For example \pd matches any "digit" character, + as does \p{digit}.

- + Word Boundaries

The following escape sequences match the boundaries of words:

- \< Matches the start of a - word. + \< Matches the start of a word.

- \> Matches the end of a word. + \> Matches the end of a word.

- \b - Matches a word boundary (the start or end of a word). + \b Matches a word boundary (the start or end of a word).

- \B - Matches only when not at a word boundary. + \B Matches only when not at a word boundary.

- + Buffer boundaries

@@ -970,46 +1026,69 @@

\Z Matches an optional sequence of newlines at the end of a buffer: equivalent - to the regular expression \n*\z + to the regular expression \n*\z

- + Continuation Escape

- The sequence \G - matches only at the end of the last match found, or at the start of the text - being matched if no previous match was found. This escape useful if you're - iterating over the matches contained within a text, and you want each subsequence - match to start where the last one ended. + The sequence \G matches only at the end of the last match + found, or at the start of the text being matched if no previous match was + found. This escape useful if you're iterating over the matches contained + within a text, and you want each subsequence match to start where the last + one ended.

- + Quoting escape

- The escape sequence \Q - begins a "quoted sequence": all the subsequent characters are treated - as literals, until either the end of the regular expression or \E is found. - For example the expression: \Q\*+\Ea+ would match either of: + The escape sequence \Q begins a "quoted sequence": + all the subsequent characters are treated as literals, until either the end + of the regular expression or \E is found. For example the expression: \Q\*+\Ea+ + would match either of:

\*+a
 \*+aaa
 
- + Unicode escapes

- \C - Matches a single code point: in Boost regex this has exactly the same effect - as a "." operator. \X Matches a combining character sequence: - that is any non-combining character followed by a sequence of zero or more - combining characters. + \C Matches a single code point: in Boost regex this has + exactly the same effect as a "." operator. \X + Matches a combining character sequence: that is any non-combining character + followed by a sequence of zero or more combining characters. +

+
+ + Matching + Line Endings +
+

+ The escape sequence \R matches any line ending character + sequence, specifically it is identical to the expression (?>\x0D\x0A?|[\x0A-\x0C\x85\x{2028}\x{2029}]). +

+
+ + Keeping + back some text +
+

+ \K Resets the start location of $0 to the current text + position: in other words everything to the left of \K is "kept back" + and does not form part of the regular expression match. $` is updated accordingly. +

+

+ For example foo\Kbar matched against the text "foobar" + would return the match "bar" for $0 and "foo" for $`. + This can be used to simulate variable width lookbehind assertions.

- + Any other escape
@@ -1018,57 +1097,54 @@ \@ matches a literal '@'.

- + Perl Extended Patterns

Perl-specific extensions to the regular expression syntax all start with - (?. + (?.

- + Comments

- (?# ... - ) is treated as a comment, it's contents - are ignored. + (?# ... ) is treated as a comment, it's contents are ignored.

- + Modifiers

- (?imsx-imsx ... ) alters - which of the perl modifiers are in effect within the pattern, changes take - effect from the point that the block is first seen and extend to any enclosing - ). Letters before a '-' turn - that perl modifier on, letters afterward, turn it off. + (?imsx-imsx ... ) alters which of the perl modifiers are + in effect within the pattern, changes take effect from the point that the + block is first seen and extend to any enclosing ). Letters + before a '-' turn that perl modifier on, letters afterward, turn it off.

- (?imsx-imsx:pattern) - applies the specified modifiers to pattern only. + (?imsx-imsx:pattern) applies the specified modifiers to + pattern only.

- + Non-marking groups

- (?:pattern) lexically groups pattern, without generating + (?:pattern) lexically groups pattern, without generating an additional sub-expression.

- + Lookahead

- (?=pattern) consumes zero characters, only if pattern + (?=pattern) consumes zero characters, only if pattern matches.

- (?!pattern) consumes zero characters, only if pattern + (?!pattern) consumes zero characters, only if pattern does not match.

@@ -1083,26 +1159,26 @@ could be used to validate the password.

- + Lookbehind

- (?<=pattern) consumes zero characters, only if pattern + (?<=pattern) consumes zero characters, only if pattern could be matched against the characters preceding the current position (pattern must be of fixed length).

- (?<!pattern) consumes zero characters, only if pattern + (?<!pattern) consumes zero characters, only if pattern could not be matched against the characters preceding the current position (pattern must be of fixed length).

- + Independent sub-expressions

- (?>pattern) pattern is matched + (?>pattern) pattern is matched independently of the surrounding patterns, the expression will never backtrack into pattern. Independent sub-expressions are typically used to improve performance; only the best possible match for pattern will @@ -1110,19 +1186,18 @@ no match is found at all.

- + Conditional Expressions

- (?(condition)yes-pattern|no-pattern) attempts to match yes-pattern - if the condition is true, otherwise attempts to match - no-pattern. + (?(condition)yes-pattern|no-pattern) attempts to match + yes-pattern if the condition is + true, otherwise attempts to match no-pattern.

- (?(condition)yes-pattern) - attempts to match yes-pattern if the condition - is true, otherwise fails. + (?(condition)yes-pattern) attempts to match yes-pattern + if the condition is true, otherwise fails.

condition may be either a forward lookahead assert, @@ -1130,7 +1205,7 @@ sub-expression has been matched).

- + Operator precedence
@@ -1143,17 +1218,16 @@ [::] [..]
  • - Escaped characters \ + Escaped characters \
  • Character set (bracket expression) []
  • - Grouping () + Grouping ()
  • - Single-character-ERE duplication * - + ? {m,n} + Single-character-ERE duplication * + ? {m,n}
  • Concatenation @@ -1166,7 +1240,7 @@
  • - + What gets matched

    @@ -1203,7 +1277,7 @@

    - AtomA AtomB + AtomA AtomB

    @@ -1216,8 +1290,7 @@

    - Expression1 | - Expression2 + Expression1 | Expression2

    @@ -1230,7 +1303,7 @@

    - S{N} + S{N}

    @@ -1242,7 +1315,7 @@

    - S{N,M} + S{N,M}

    @@ -1254,7 +1327,7 @@

    - S{N,M}? + S{N,M}?

    @@ -1266,41 +1339,33 @@

    - S?, - S*, - S+ + S?, S*, S+

    - The same as S{0,1}, - S{0,UINT_MAX}, - S{1,UINT_MAX} - respectively. + The same as S{0,1}, S{0,UINT_MAX}, + S{1,UINT_MAX} respectively.

    - S??, - S*?, - S+? + S??, S*?, S+?

    - The same as S{0,1}?, - S{0,UINT_MAX}?, - S{1,UINT_MAX}? - respectively. + The same as S{0,1}?, S{0,UINT_MAX}?, + S{1,UINT_MAX}? respectively.

    - (?>S) + (?>S)

    @@ -1312,7 +1377,7 @@

    - (?=S), (?<=S) + (?=S), (?<=S)

    @@ -1325,7 +1390,7 @@

    - (?!S), (?<!S) + (?!S), (?<!S)

    @@ -1337,8 +1402,7 @@

    - (?(condition)yes-pattern - | no-pattern) + (?(condition)yes-pattern | no-pattern)

    @@ -1351,41 +1415,40 @@

    - + Variations

    The options - normal, ECMAScript, - JavaScript and JScript are all synonyms for perl. + normal, ECMAScript, JavaScript + and JScript are all synonyms for perl.

    - + Options

    There are a variety - of flags that may be combined with the perl - option when constructing the regular expression, in particular note that - the newline_alt option alters - the syntax, while the collate, - nosubs and icase options modify how the case and locale - sensitivity are to be applied. + of flags that may be combined with the perl option + when constructing the regular expression, in particular note that the newline_alt + option alters the syntax, while the collate, nosubs + and icase options modify how the case and locale sensitivity + are to be applied.

    - + Pattern Modifiers

    - The perl smix modifiers can - either be applied using a (?smix-smix) prefix to the regular expression, or with + The perl smix modifiers can either be applied using a + (?smix-smix) prefix to the regular expression, or with one of the regex-compile - time flags no_mod_m, mod_x, mod_s, - and no_mod_s. + time flags no_mod_m, mod_x, mod_s, + and no_mod_s.

    - + References

    diff --git a/doc/html/boost_regex/unicode.html b/doc/html/boost_regex/unicode.html index 00b14229..a21286ca 100644 --- a/doc/html/boost_regex/unicode.html +++ b/doc/html/boost_regex/unicode.html @@ -30,7 +30,7 @@ There are two ways to use Boost.Regex with Unicode strings:

    - + Rely on wchar_t

    @@ -56,7 +56,7 @@

    - + Use a Unicode Aware Regular Expression Type.
    diff --git a/doc/html/index.html b/doc/html/index.html index 365165f2..6945b093 100644 --- a/doc/html/index.html +++ b/doc/html/index.html @@ -28,7 +28,7 @@
    -

    +

    Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

    @@ -196,7 +196,7 @@

    - +

    Last revised: April 23, 2009 at 09:45:24 GMT

    Last revised: April 25, 2009 at 17:20:04 GMT


    diff --git a/doc/syntax_perl.qbk b/doc/syntax_perl.qbk index b3b4056f..a67bc771 100644 --- a/doc/syntax_perl.qbk +++ b/doc/syntax_perl.qbk @@ -12,7 +12,7 @@ The Perl regular expression syntax is based on that used by the programming language Perl . Perl regular expressions are the -default behavior in Boost.Regex or you can pass the flag `perl` to the +default behavior in Boost.Regex or you can pass the flag =perl= to the [basic_regex] constructor, for example: // e1 is a case sensitive Perl regular expression: @@ -34,9 +34,9 @@ The single character '.' when used outside of a character set will match any single character except: * The NULL character when the [link boost_regex.ref.match_flag_type flag - `match_not_dot_null`] is passed to the matching algorithms. + =match_not_dot_null=] is passed to the matching algorithms. * The newline character when the [link boost_regex.ref.match_flag_type - flag `match_not_dot_newline`] is passed to + flag =match_not_dot_newline=] is passed to the matching algorithms. [h4 Anchors] @@ -47,7 +47,7 @@ A '$' character shall match the end of a line. [h4 Marked sub-expressions] -A section beginning `(` and ending `)` acts as a marked sub-expression. +A section beginning =(= and ending =)= acts as a marked sub-expression. Whatever matched the sub-expression is split out in a separate field by the matching algorithms. Marked sub-expressions can also repeated, or referred to by a back-reference. @@ -58,23 +58,23 @@ A marked sub-expression is useful to lexically group part of a regular expression, but has the side-effect of spitting out an extra field in the result. As an alternative you can lexically group part of a regular expression, without generating a marked sub-expression by using -`(?:` and `)` , for example `(?:ab)+` will repeat `ab` without splitting +=(?:= and =)= , for example =(?:ab)+= will repeat =ab= without splitting out any separate sub-expressions. [h4 Repeats] Any atom (a single character, a marked sub-expression, or a character class) -can be repeated with the `*`, `+`, `?`, and `{}` operators. +can be repeated with the =*=, =+=, =?=, and ={}= operators. -The `*` operator will match the preceding atom zero or more times, -for example the expression `a*b` will match any of the following: +The =*= operator will match the preceding atom zero or more times, +for example the expression =a*b= will match any of the following: b ab aaaaaaaab -The `+` operator will match the preceding atom one or more times, for -example the expression `a+b` will match any of the following: +The =+= operator will match the preceding atom one or more times, for +example the expression =a+b= will match any of the following: ab aaaaaaaab @@ -83,7 +83,7 @@ But will not match: b -The `?` operator will match the preceding atom zero or one times, for +The =?= operator will match the preceding atom zero or one times, for example the expression ca?b will match any of the following: cb @@ -95,11 +95,11 @@ But will not match: An atom can also be repeated with a bounded repeat: -`a{n}` Matches 'a' repeated exactly n times. +=a{n}= Matches 'a' repeated exactly n times. -`a{n,}` Matches 'a' repeated n or more times. +=a{n,}= Matches 'a' repeated n or more times. -`a{n, m}` Matches 'a' repeated between n and m times inclusive. +=a{n, m}= Matches 'a' repeated between n and m times inclusive. For example: @@ -120,7 +120,7 @@ be repeated, for example: a(*) -Will raise an error, as there is nothing for the `*` operator to be applied to. +Will raise an error, as there is nothing for the =*= operator to be applied to. [h4 Non greedy repeats] @@ -128,19 +128,19 @@ The normal repeat operators are "greedy", that is to say they will consume as much input as possible. There are non-greedy versions available that will consume as little input as possible while still producing a match. -`*?` Matches the previous atom zero or more times, while consuming as little +=*?= Matches the previous atom zero or more times, while consuming as little input as possible. -`+?` Matches the previous atom one or more times, while consuming as +=+?= Matches the previous atom one or more times, while consuming as little input as possible. -`??` Matches the previous atom zero or one times, while consuming +=??= Matches the previous atom zero or one times, while consuming as little input as possible. -`{n,}?` Matches the previous atom n or more times, while consuming as +={n,}?= Matches the previous atom n or more times, while consuming as little input as possible. -`{n,m}?` Matches the previous atom between n and m times, while +={n,m}?= Matches the previous atom between n and m times, while consuming as little input as possible. [h4 Pocessive repeats] @@ -150,15 +150,15 @@ a match is found. However, this behaviour can sometime be undesireable so there also "pocessive" repeats: these match as much as possible and do not then allow backtracking if the rest of the expression fails to match. -`*+` Matches the previous atom zero or more times, while giving nothing back. +=*+= Matches the previous atom zero or more times, while giving nothing back. -`++` Matches the previous atom one or more times, while giving nothing back. +=++= Matches the previous atom one or more times, while giving nothing back. -`?+` Matches the previous atom zero or one times, while giving nothing back. +=?+= Matches the previous atom zero or one times, while giving nothing back. -`{n,}+` Matches the previous atom n or more times, while giving nothing back. +={n,}+= Matches the previous atom n or more times, while giving nothing back. -`{n,m}+` Matches the previous atom between n and m times, while giving nothing back. +={n,m}+= Matches the previous atom between n and m times, while giving nothing back. [h4 Back references] @@ -175,27 +175,38 @@ Will match the string: But not the string: aaabba + +You can also use the \g escape for the same function, for example: + +[table +[[Escape][Meaning]] +[[=\g1=][Match whatever matched sub-expression 1]] +[[=\g{1}=][Match whatever matched sub-expression 1: this form allows for safer + parsing of the expression in cases like =\g{1}2= or for indexes higher than 9 as in =\g{1234}=]] +[[=\g-1=][Match whatever matched the last opened sub-expression]] +[[=\g{-2}=][Match whatever matched the last but one opened sub-expression]] +] [h4 Alternation] -The `|` operator will match either of its arguments, so for example: -`abc|def` will match either "abc" or "def". +The =|= operator will match either of its arguments, so for example: +=abc|def= will match either "abc" or "def". -Parenthesis can be used to group alternations, for example: `ab(d|ef)` +Parenthesis can be used to group alternations, for example: =ab(d|ef)= will match either of "abd" or "abef". Empty alternatives are not allowed (these are almost always a mistake), but -if you really want an empty alternative use `(?:)` as a placeholder, for example: +if you really want an empty alternative use =(?:)= as a placeholder, for example: -`|abc` is not a valid expression, but +=|abc= is not a valid expression, but -`(?:)|abc` is and is equivalent, also the expression: +=(?:)|abc= is and is equivalent, also the expression: -`(?:abc)??` has exactly the same effect. +=(?:abc)??= has exactly the same effect. [h4 Character sets] -A character set is a bracket-expression starting with `[` and ending with `]`, +A character set is a bracket-expression starting with =[= and ending with =]=, it defines a set of characters, and matches any single character that is a member of that set. @@ -203,35 +214,35 @@ A bracket expression may contain any combination of the following: [h5 Single characters] -For example `[abc]`, will match any of the characters 'a', 'b', or 'c'. +For example =[abc]=, will match any of the characters 'a', 'b', or 'c'. [h5 Character ranges] -For example `[a-c]` will match any single character in the range 'a' to 'c'. +For example =[a-c]= will match any single character in the range 'a' to 'c'. By default, for Perl regular expressions, a character x is within the range y to z, if the code point of the character lies within the codepoints of the endpoints of the range. Alternatively, if you set the -[link boost_regex.ref.syntax_option_type.syntax_option_type_perl `collate` flag] +[link boost_regex.ref.syntax_option_type.syntax_option_type_perl =collate= flag] when constructing the regular expression, then ranges are locale sensitive. [h5 Negation] If the bracket-expression begins with the ^ character, then it matches the -complement of the characters it contains, for example `[^a-c]` matches -any character that is not in the range `a-c`. +complement of the characters it contains, for example =[^a-c]= matches +any character that is not in the range =a-c=. [h5 Character classes] -An expression of the form `[[:name:]]` matches the named character class -"name", for example `[[:lower:]]` matches any lower case character. +An expression of the form [^\[\[:name:\]\]] matches the named character class +"name", for example [^\[\[:lower:\]\]] matches any lower case character. See [link boost_regex.syntax.character_classes character class names]. [h5 Collating Elements] -An expression of the form `[[.col.]` matches the collating element /col/. +An expression of the form [^\[\[.col.\]\]] matches the collating element /col/. A collating element is any single character, or any sequence of characters that collates as a single unit. Collating elements may also be used -as the end point of a range, for example: `[[.ae.]-c]` matches the +as the end point of a range, for example: [^\[\[.ae.\]-c\]] matches the character sequence "ae", plus any single character in the range "ae"-c, assuming that "ae" is treated as a single collating element in the current locale. @@ -240,11 +251,11 @@ As an extension, a collating element may also be specified via it's [[.NUL.]] -matches a `\0` character. +matches a =\0= character. [h5 Equivalence classes] -An expression of the form `[[=col=]]`, matches any character or collating element +An expression of the form [^\[\[\=col\=\]\]], matches any character or collating element whose primary sort key is the same as that for collating element /col/, as with collating elements the name /col/ may be a [link boost_regex.syntax.collating_names symbolic name]. A primary sort key is @@ -267,7 +278,7 @@ that is either a "digit", /or/ is /not/ a "word" character. [h5 Combinations] All of the above can be combined in one character set declaration, for example: -`[[:digit:]a-c[.NUL.]]`. +[^\[\[:digit:\]a-c\[.NUL.\]\]]. [h4 Escapes] @@ -277,24 +288,24 @@ The following escape sequences are all synonyms for single characters: [table [[Escape][Character]] -[[`\a`][`\a`]] -[[`\e`][`0x1B`]] -[[`\f`][`\f`]] -[[`\n`][`\n`]] -[[`\r`][`\r`]] -[[`\t`][`\t`]] -[[`\v `][`\v`]] -[[`\b`][`\b` (but only inside a character class declaration).]] -[[`\cX`][An ASCII escape sequence - the character whose code point is X % 32]] -[[`\xdd`][A hexadecimal escape sequence - matches the single character whose +[[=\a=][=\a=]] +[[=\e=][=0x1B=]] +[[=\f=][=\f=]] +[[=\n=][=\n=]] +[[=\r=][=\r=]] +[[=\t=][=\t=]] +[[=\v=][=\v=]] +[[=\b=][=\b= (but only inside a character class declaration).]] +[[=\cX=][An ASCII escape sequence - the character whose code point is X % 32]] +[[=\xdd=][A hexadecimal escape sequence - matches the single character whose code point is 0xdd.]] -[[`\x{dddd}`][A hexadecimal escape sequence - matches the single character whose +[[=\x{dddd}=][A hexadecimal escape sequence - matches the single character whose code point is 0xdddd.]] -[[`\0ddd`][An octal escape sequence - matches the single character whose +[[=\0ddd=][An octal escape sequence - matches the single character whose code point is 0ddd.]] -[[`\N{name}`][Matches the single character which has the +[[=\N{name}=][Matches the single character which has the [link boost_regex.syntax.collating_names symbolic name] /name/. - For example `\N{newline}` matches the single character \\n.]] + For example =\N{newline}= matches the single character \\n.]] ] [h5 "Single character" character classes:] @@ -337,19 +348,19 @@ to the [link boost_regex.syntax.character_classes names used in character classe [[`\P{Name}`][Matches any character that does not have the property Name.][`[^[:Name:]]`]] ] -For example `\pd` matches any "digit" character, as does `\p{digit}`. +For example =\pd= matches any "digit" character, as does =\p{digit}=. [h5 Word Boundaries] The following escape sequences match the boundaries of words: -`\<` Matches the start of a word. +=\<= Matches the start of a word. -`\>` Matches the end of a word. +=\>= Matches the end of a word. -`\b` Matches a word boundary (the start or end of a word). +=\b= Matches a word boundary (the start or end of a word). -`\B` Matches only when not at a word boundary. +=\B= Matches only when not at a word boundary. [h5 Buffer boundaries] @@ -366,30 +377,44 @@ context is the whole of the input text that is being matched against \\z Matches at the end of a buffer only (the same as \\'). \\Z Matches an optional sequence of newlines at the end of a buffer: -equivalent to the regular expression `\n*\z` +equivalent to the regular expression =\n*\z= [h5 Continuation Escape] -The sequence `\G` matches only at the end of the last match found, or at +The sequence =\G= matches only at the end of the last match found, or at the start of the text being matched if no previous match was found. This escape useful if you're iterating over the matches contained within a text, and you want each subsequence match to start where the last one ended. [h5 Quoting escape] -The escape sequence `\Q` begins a "quoted sequence": all the subsequent characters +The escape sequence =\Q= begins a "quoted sequence": all the subsequent characters are treated as literals, until either the end of the regular expression or \\E -is found. For example the expression: `\Q\*+\Ea+` would match either of: +is found. For example the expression: =\Q\*+\Ea+= would match either of: \*+a \*+aaa [h5 Unicode escapes] -`\C` Matches a single code point: in Boost regex this has exactly the +=\C= Matches a single code point: in Boost regex this has exactly the same effect as a "." operator. -`\X` Matches a combining character sequence: that is any non-combining +=\X= Matches a combining character sequence: that is any non-combining character followed by a sequence of zero or more combining characters. + +[h5 Matching Line Endings] + +The escape sequence =\R= matches any line ending character sequence, specifically it is identical to +the expression [^(?>\x0D\x0A?|\[\x0A-\x0C\x85\x{2028}\x{2029}\])]. + +[h5 Keeping back some text] + +=\K= Resets the start location of $0 to the current text position: in other words everything to the +left of \K is "kept back" and does not form part of the regular expression match. $` is updated +accordingly. + +For example =foo\Kbar= matched against the text "foobar" would return the match "bar" for $0 and "foo" +for $`. This can be used to simulate variable width lookbehind assertions. [h5 Any other escape] @@ -398,31 +423,31 @@ Any other escape sequence matches the character that is escaped, for example [h4 Perl Extended Patterns] -Perl-specific extensions to the regular expression syntax all start with `(?`. +Perl-specific extensions to the regular expression syntax all start with =(?=. [h5 Comments] -`(?# ... )` is treated as a comment, it's contents are ignored. +=(?# ... )= is treated as a comment, it's contents are ignored. [h5 Modifiers] -`(?imsx-imsx ... )` alters which of the perl modifiers are in effect within +=(?imsx-imsx ... )= alters which of the perl modifiers are in effect within the pattern, changes take effect from the point that the block is first seen -and extend to any enclosing `)`. Letters before a '-' turn that perl +and extend to any enclosing =)=. Letters before a '-' turn that perl modifier on, letters afterward, turn it off. -`(?imsx-imsx:pattern)` applies the specified modifiers to pattern only. +=(?imsx-imsx:pattern)= applies the specified modifiers to pattern only. [h5 Non-marking groups] -`(?:pattern)` lexically groups pattern, without generating an additional +=(?:pattern)= lexically groups pattern, without generating an additional sub-expression. [h5 Lookahead] -`(?=pattern)` consumes zero characters, only if pattern matches. +[^(?=pattern)] consumes zero characters, only if pattern matches. -`(?!pattern)` consumes zero characters, only if pattern does not match. +=(?!pattern)= consumes zero characters, only if pattern does not match. Lookahead is typically used to create the logical AND of two regular expressions, for example if a password must contain a lower case letter, @@ -435,17 +460,17 @@ could be used to validate the password. [h5 Lookbehind] -`(?<=pattern)` consumes zero characters, only if pattern could be matched +[^(?<=pattern)] consumes zero characters, only if pattern could be matched against the characters preceding the current position (pattern must be of fixed length). -`(?pattern)` /pattern/ is matched independently of the surrounding patterns, +=(?>pattern)= /pattern/ is matched independently of the surrounding patterns, the expression will never backtrack into /pattern/. Independent sub-expressions are typically used to improve performance; only the best possible match for pattern will be considered, if this doesn't allow the expression as a @@ -453,10 +478,10 @@ whole to match then no match is found at all. [h5 Conditional Expressions] -`(?(condition)yes-pattern|no-pattern)` attempts to match /yes-pattern/ if +=(?(condition)yes-pattern|no-pattern)= attempts to match /yes-pattern/ if the /condition/ is true, otherwise attempts to match /no-pattern/. -`(?(condition)yes-pattern)` attempts to match /yes-pattern/ if the /condition/ +=(?(condition)yes-pattern)= attempts to match /yes-pattern/ if the /condition/ is true, otherwise fails. /condition/ may be either a forward lookahead assert, or the index of @@ -468,10 +493,10 @@ has been matched). The order of precedence for of operators is as follows: # Collation-related bracket symbols `[==] [::] [..]` -# Escaped characters `\` +# Escaped characters =\= # Character set (bracket expression) `[]` -# Grouping `()` -# Single-character-ERE duplication `* + ? {m,n}` +# Grouping =()= +# Single-character-ERE duplication =* + ? {m,n}= # Concatenation # Anchoring ^$ # Alternation | @@ -490,42 +515,42 @@ with individual elements matched as follows; [table [[Construct][What gets matched]] -[[`AtomA AtomB`][Locates the best match for /AtomA/ that has a following match for /AtomB/.]] -[[`Expression1 | Expression2`][If /Expresion1/ can be matched then returns that match, +[[=AtomA AtomB=][Locates the best match for /AtomA/ that has a following match for /AtomB/.]] +[[=Expression1 | Expression2=][If /Expresion1/ can be matched then returns that match, otherwise attempts to match /Expression2/.]] -[[`S{N}`][Matches /S/ repeated exactly N times.]] -[[`S{N,M}`][Matches S repeated between N and M times, and as many times as possible.]] -[[`S{N,M}?`][Matches S repeated between N and M times, and as few times as possible.]] -[[`S?, S*, S+`][The same as `S{0,1}`, `S{0,UINT_MAX}`, `S{1,UINT_MAX}` respectively.]] -[[`S??, S*?, S+?`][The same as `S{0,1}?`, `S{0,UINT_MAX}?`, `S{1,UINT_MAX}?` respectively.]] -[[`(?>S)`][Matches the best match for /S/, and only that.]] -[[`(?=S), (?<=S)`][Matches only the best match for /S/ (this is only +[[=S{N}=][Matches /S/ repeated exactly N times.]] +[[=S{N,M}=][Matches S repeated between N and M times, and as many times as possible.]] +[[=S{N,M}?=][Matches S repeated between N and M times, and as few times as possible.]] +[[=S?, S*, S+=][The same as =S{0,1}=, =S{0,UINT_MAX}=, =S{1,UINT_MAX}= respectively.]] +[[=S??, S*?, S+?=][The same as =S{0,1}?=, =S{0,UINT_MAX}?=, =S{1,UINT_MAX}?= respectively.]] +[[=(?>S)=][Matches the best match for /S/, and only that.]] +[[[^(?=S), (?<=S)]][Matches only the best match for /S/ (this is only visible if there are capturing parenthesis within /S/).]] -[[`(?!S), (?flags() & (regbase::main_option_type | regbase::no_perl_ex))) + { + re_brace* pb = static_cast(this->append_state(syntax_element_startmark, sizeof(re_brace))); + pb->index = -5; + this->m_pdata->m_data.align(); + ++m_position; + return true; + } + goto escape_type_class_jump; + case regex_constants::escape_type_line_ending: + if(0 == (this->flags() & (regbase::main_option_type | regbase::no_perl_ex))) + { + const charT* e = get_escape_R_string(); + const charT* old_position = m_position; + const charT* old_end = m_end; + const charT* old_base = m_base; + m_position = e; + m_base = e; + m_end = e + traits::length(e); + bool r = parse_all(); + m_position = ++old_position; + m_end = old_end; + m_base = old_base; + return r; + } + goto escape_type_class_jump; + case regex_constants::escape_type_extended_backref: + if(0 == (this->flags() & (regbase::main_option_type | regbase::no_perl_ex))) + { + bool have_brace = false; + bool negative = false; + if(++m_position == m_end) + { + fail(regex_constants::error_escape, m_position - m_base); + return false; + } + // maybe have \g{ddd} + if(this->m_traits.syntax_type(*m_position) == regex_constants::syntax_open_brace) + { + if(++m_position == m_end) + { + fail(regex_constants::error_escape, m_position - m_base); + return false; + } + have_brace = true; + } + negative = (*m_position == static_cast('-')); + if((negative) && (++m_position == m_end)) + { + fail(regex_constants::error_escape, m_position - m_base); + return false; + } + const charT* pc = m_position; + int i = this->m_traits.toi(pc, m_end, 10); + if(negative) + i = 1 + m_mark_count - i; + if((i > 0) && (this->m_backrefs & (1u << (i-1)))) + { + m_position = pc; + re_brace* pb = static_cast(this->append_state(syntax_element_backref, sizeof(re_brace))); + pb->index = i; + } + else + { + fail(regex_constants::error_backref, m_position - m_end); + return false; + } + m_position = pc; + if(have_brace) + { + if((m_position == m_end) || (this->m_traits.syntax_type(*m_position) != regex_constants::syntax_close_brace)) + { + fail(regex_constants::error_escape, m_position - m_base); + return false; + } + ++m_position; + } + return true; + } + goto escape_type_class_jump; case regex_constants::escape_type_control_v: if(0 == (this->flags() & (regbase::main_option_type | regbase::no_perl_ex))) goto escape_type_class_jump; @@ -1499,7 +1581,7 @@ charT basic_regex_parser::unescape_character() int i = this->m_traits.toi(m_position, m_end, 16); if((m_position == m_end) || (i < 0) - || ((std::numeric_limits::is_specialized) && (charT(i) > (std::numeric_limits::max)())) + || ((std::numeric_limits::is_specialized) && (i > (int)(std::numeric_limits::max)())) || (this->m_traits.syntax_type(*m_position) != regex_constants::syntax_close_brace)) { fail(regex_constants::error_badbrace, m_position - m_base); diff --git a/include/boost/regex/v4/match_results.hpp b/include/boost/regex/v4/match_results.hpp index acf509fa..5642508b 100644 --- a/include/boost/regex/v4/match_results.hpp +++ b/include/boost/regex/v4/match_results.hpp @@ -230,13 +230,13 @@ public: m_null.matched = false; } - void BOOST_REGEX_CALL set_second(BidiIterator i, size_type pos, bool m = true) + void BOOST_REGEX_CALL set_second(BidiIterator i, size_type pos, bool m = true, bool escape_k = false) { pos += 2; BOOST_ASSERT(m_subs.size() > pos); m_subs[pos].second = i; m_subs[pos].matched = m; - if(pos == 2) + if((pos == 2) && !escape_k) { m_subs[0].first = i; m_subs[0].matched = (m_subs[0].first != m_subs[0].second); @@ -284,11 +284,18 @@ public: m_subs[n].matched = false; } } - void BOOST_REGEX_CALL set_first(BidiIterator i, size_type pos) + void BOOST_REGEX_CALL set_first(BidiIterator i, size_type pos, bool escape_k = false) { BOOST_ASSERT(pos+2 < m_subs.size()); - if(pos) + if(pos || escape_k) + { m_subs[pos+2].first = i; + if(escape_k) + { + m_subs[1].second = i; + m_subs[1].matched = (m_subs[1].first != m_subs[1].second); + } + } else set_first(i); } diff --git a/include/boost/regex/v4/perl_matcher_common.hpp b/include/boost/regex/v4/perl_matcher_common.hpp index 399caa3b..1be1af6f 100644 --- a/include/boost/regex/v4/perl_matcher_common.hpp +++ b/include/boost/regex/v4/perl_matcher_common.hpp @@ -205,7 +205,7 @@ bool perl_matcher::match_imp() verify_options(re.flags(), m_match_flags); if(0 == match_prefix()) return false; - return m_result[0].second == last; + return (m_result[0].second == last) && (m_result[0].first == base); #if defined(BOOST_REGEX_NON_RECURSIVE) && !defined(BOOST_NO_EXCEPTIONS) } diff --git a/include/boost/regex/v4/perl_matcher_non_recursive.hpp b/include/boost/regex/v4/perl_matcher_non_recursive.hpp index 6cb6d3da..572e32a6 100644 --- a/include/boost/regex/v4/perl_matcher_non_recursive.hpp +++ b/include/boost/regex/v4/perl_matcher_non_recursive.hpp @@ -213,7 +213,7 @@ void perl_matcher::extend_stack() template inline void perl_matcher::push_matched_paren(int index, const sub_match& sub) { - BOOST_ASSERT(index); + //BOOST_ASSERT(index); saved_matched_paren* pmp = static_cast*>(m_backup_state); --pmp; if(pmp < m_stack_base) @@ -404,6 +404,13 @@ bool perl_matcher::match_startmark() break; } } + case -5: + { + push_matched_paren(0, (*m_presult)[0]); + m_presult->set_first(position, 0, true); + pstate = pstate->next.p; + break; + } default: { BOOST_ASSERT(index > 0); @@ -911,8 +918,8 @@ bool perl_matcher::unwind_paren(bool have_match // restore previous values if no match was found: if(have_match == false) { - m_presult->set_first(pmp->sub.first, pmp->index); - m_presult->set_second(pmp->sub.second, pmp->index, pmp->sub.matched); + m_presult->set_first(pmp->sub.first, pmp->index, pmp->index == 0); + m_presult->set_second(pmp->sub.second, pmp->index, pmp->sub.matched, pmp->index == 0); } #ifdef BOOST_REGEX_MATCH_EXTRA // diff --git a/include/boost/regex/v4/perl_matcher_recursive.hpp b/include/boost/regex/v4/perl_matcher_recursive.hpp index 75df4507..bc0fe958 100644 --- a/include/boost/regex/v4/perl_matcher_recursive.hpp +++ b/include/boost/regex/v4/perl_matcher_recursive.hpp @@ -51,8 +51,8 @@ public: template void restore(match_results& w) { - w.set_first(sub.first, index); - w.set_second(sub.second, index, sub.matched); + w.set_first(sub.first, index, index == 0); + w.set_second(sub.second, index, sub.matched, index == 0); } const sub_match& get() { return sub; } }; @@ -209,6 +209,17 @@ bool perl_matcher::match_startmark() break; } } + case -5: + { + // Reset start of $0, since we have a \K escape + backup_subex sub(*m_presult, 0); + m_presult->set_first(position, 0, true); + pstate = pstate->next.p; + r = match_all_states(); + if(r == false) + sub.restore(*m_presult); + break; + } default: { BOOST_ASSERT(index > 0); diff --git a/include/boost/regex/v4/regex_traits_defaults.hpp b/include/boost/regex/v4/regex_traits_defaults.hpp index 8f33d2c8..c213889c 100644 --- a/include/boost/regex/v4/regex_traits_defaults.hpp +++ b/include/boost/regex/v4/regex_traits_defaults.hpp @@ -317,6 +317,28 @@ int global_toi(const charT*& p1, const charT* p2, int radix, const traits& t) return result; } +template +inline const charT* get_escape_R_string() +{ +#ifdef BOOST_MSVC +# pragma warning(push) +# pragma warning(disable:4309) +#endif + static const charT e1[] = { '(', '?', '>', '\x0D', '\x0A', '?', + '|', '[', '\x0A', '\x0B', '\x0C', '\x85', '\\', 'x', '{', '2', '0', '2', '8', '}', + '\\', 'x', '{', '2', '0', '2', '9', '}', ']', ')' }; + static const charT e2[] = { '(', '?', '>', '\x0D', '\x0A', '?', + '|', '[', '\x0A', '\x0B', '\x0C', '\x85', ']', ')' }; + + charT c = static_cast(0x2029u); + bool b = (static_cast(c) == 0x2029u); + + return (b ? e1 : e2); +#ifdef BOOST_MSVC +# pragma warning(pop) +#endif +} + } // re_detail } // boost diff --git a/include/boost/regex/v4/syntax_type.hpp b/include/boost/regex/v4/syntax_type.hpp index 92c00d4c..3efdf0b0 100644 --- a/include/boost/regex/v4/syntax_type.hpp +++ b/include/boost/regex/v4/syntax_type.hpp @@ -92,8 +92,11 @@ static const escape_syntax_type escape_type_G = 52; / static const escape_syntax_type escape_type_property = 54; // for \p static const escape_syntax_type escape_type_not_property = 55; // for \P static const escape_syntax_type escape_type_named_char = 56; // for \N +static const escape_syntax_type escape_type_extended_backref = 57; // for \g +static const escape_syntax_type escape_type_reset_start_mark = 58; // for \K +static const escape_syntax_type escape_type_line_ending = 59; // for \R -static const escape_syntax_type syntax_max = 57; +static const escape_syntax_type syntax_max = 60; } } diff --git a/src/regex_traits_defaults.cpp b/src/regex_traits_defaults.cpp index 8f76c09e..96ea0b3d 100644 --- a/src/regex_traits_defaults.cpp +++ b/src/regex_traits_defaults.cpp @@ -100,6 +100,9 @@ BOOST_REGEX_DECL const char* BOOST_REGEX_CALL get_default_syntax(regex_constants "p", "P", "N", + "g", + "K", + "R", }; return ((n >= (sizeof(messages) / sizeof(messages[1]))) ? "" : messages[n]); @@ -375,14 +378,14 @@ BOOST_REGEX_DECL regex_constants::escape_syntax_type BOOST_REGEX_CALL get_defaul regex_constants::escape_type_not_class, /*H*/ regex_constants::escape_type_not_class, /*I*/ regex_constants::escape_type_not_class, /*J*/ - regex_constants::escape_type_not_class, /*K*/ + regex_constants::escape_type_reset_start_mark, /*K*/ regex_constants::escape_type_not_class, /*L*/ regex_constants::escape_type_not_class, /*M*/ regex_constants::escape_type_named_char, /*N*/ regex_constants::escape_type_not_class, /*O*/ regex_constants::escape_type_not_property, /*P*/ regex_constants::escape_type_Q, /*Q*/ - regex_constants::escape_type_not_class, /*R*/ + regex_constants::escape_type_line_ending, /*R*/ regex_constants::escape_type_not_class, /*S*/ regex_constants::escape_type_not_class, /*T*/ regex_constants::escape_type_not_class, /*U*/ @@ -403,11 +406,11 @@ BOOST_REGEX_DECL regex_constants::escape_syntax_type BOOST_REGEX_CALL get_defaul regex_constants::escape_type_class, /*d*/ regex_constants::escape_type_e, /*e*/ regex_constants::escape_type_control_f, /*f*/ - regex_constants::escape_type_class, /*g*/ + regex_constants::escape_type_extended_backref, /*g*/ regex_constants::escape_type_class, /*h*/ regex_constants::escape_type_class, /*i*/ regex_constants::escape_type_class, /*j*/ - regex_constants::escape_type_class, /*k*/ + regex_constants::escape_type_extended_backref, /*k*/ regex_constants::escape_type_class, /*l*/ regex_constants::escape_type_class, /*m*/ regex_constants::escape_type_control_n, /*n*/ diff --git a/test/regress/test_backrefs.cpp b/test/regress/test_backrefs.cpp index 3702b486..e5c254ff 100644 --- a/test/regress/test_backrefs.cpp +++ b/test/regress/test_backrefs.cpp @@ -55,5 +55,40 @@ void test_backrefs() TEST_REGEX_SEARCH("\\(a\\)\\1bc*[ce]d", basic, "aabcccd", match_default, make_array(0, 7, 0, 1, -2, -2)); TEST_REGEX_SEARCH("^\\(a\\)\\1b\\(c\\)*cd$", basic, "aabcccd", match_default, make_array(0, 7, 0, 1, 4, 5, -2, -2)); TEST_REGEX_SEARCH("\\(ab*\\)[ab]*\\1", basic, "ababaaa", match_default, make_array(0, 7, 0, 1, -2, -2)); + // + // Now test the \g version: + // + TEST_INVALID_REGEX("a(b)\\g2c", perl); + TEST_INVALID_REGEX("a(b\\g1)c", perl); + TEST_INVALID_REGEX("a(b\\g0)c", perl); + TEST_REGEX_SEARCH("a(b*)c\\g1d", perl, "abbcbbd", match_default, make_array(0, 7, 1, 3, -2, -2)); + TEST_REGEX_SEARCH("a(b*)c\\g1d", perl, "abbcbd", match_default, make_array(-2, -2)); + TEST_REGEX_SEARCH("a(b*)c\\g1d", perl, "abbcbbbd", match_default, make_array(-2, -2)); + TEST_REGEX_SEARCH("^(.)\\g1", perl, "abc", match_default, make_array(-2, -2)); + TEST_REGEX_SEARCH("a([bc])\\g1d", perl, "abcdabbd", match_default, make_array(4, 8, 5, 6, -2, -2)); + TEST_INVALID_REGEX("a(b)\\g{2}c", perl); + TEST_INVALID_REGEX("a(b\\g{1})c", perl); + TEST_INVALID_REGEX("a(b\\g{0})c", perl); + TEST_REGEX_SEARCH("a(b*)c\\g{1}d", perl, "abbcbbd", match_default, make_array(0, 7, 1, 3, -2, -2)); + TEST_REGEX_SEARCH("a(b*)c\\g{1}d", perl, "abbcbd", match_default, make_array(-2, -2)); + TEST_REGEX_SEARCH("a(b*)c\\g{1}d", perl, "abbcbbbd", match_default, make_array(-2, -2)); + TEST_REGEX_SEARCH("^(.)\\g{1}", perl, "abc", match_default, make_array(-2, -2)); + TEST_REGEX_SEARCH("a([bc])\\g{1}d", perl, "abcdabbd", match_default, make_array(4, 8, 5, 6, -2, -2)); + // And again but with negative indexes: + TEST_INVALID_REGEX("a(b)\\g-2c", perl); + TEST_INVALID_REGEX("a(b\\g-1)c", perl); + TEST_INVALID_REGEX("a(b\\g-0)c", perl); + TEST_REGEX_SEARCH("a(b*)c\\g-1d", perl, "abbcbbd", match_default, make_array(0, 7, 1, 3, -2, -2)); + TEST_REGEX_SEARCH("a(b*)c\\g-1d", perl, "abbcbd", match_default, make_array(-2, -2)); + TEST_REGEX_SEARCH("a(b*)c\\g-1d", perl, "abbcbbbd", match_default, make_array(-2, -2)); + TEST_REGEX_SEARCH("^(.)\\g1", perl, "abc", match_default, make_array(-2, -2)); + TEST_REGEX_SEARCH("a([bc])\\g1d", perl, "abcdabbd", match_default, make_array(4, 8, 5, 6, -2, -2)); + TEST_INVALID_REGEX("a(b)\\g{-2}c", perl); + TEST_INVALID_REGEX("a(b\\g{-1})c", perl); + TEST_REGEX_SEARCH("a(b*)c\\g{-1}d", perl, "abbcbbd", match_default, make_array(0, 7, 1, 3, -2, -2)); + TEST_REGEX_SEARCH("a(b*)c\\g{-1}d", perl, "abbcbd", match_default, make_array(-2, -2)); + TEST_REGEX_SEARCH("a(b*)c\\g{-1}d", perl, "abbcbbbd", match_default, make_array(-2, -2)); + TEST_REGEX_SEARCH("^(.)\\g{-1}", perl, "abc", match_default, make_array(-2, -2)); + TEST_REGEX_SEARCH("a([bc])\\g{-1}d", perl, "abcdabbd", match_default, make_array(4, 8, 5, 6, -2, -2)); } diff --git a/test/regress/test_escapes.cpp b/test/regress/test_escapes.cpp index ba78c454..21d4262f 100644 --- a/test/regress/test_escapes.cpp +++ b/test/regress/test_escapes.cpp @@ -144,5 +144,23 @@ void test_assertion_escapes() TEST_REGEX_SEARCH("a\\Gbc", perl, "abc", match_default, make_array(-2, -2)); TEST_REGEX_SEARCH("a\\Aab", perl, "abc", match_default, make_array(-2, -2)); TEST_REGEX_SEARCH("abc(?:\\Z|$)", perl, "abc\n\n", match_default, make_array(0, 3, -2, -2)); + + // Buffer reset \K: + TEST_REGEX_SEARCH("(foo)\\Kbar", perl, "foobar", match_default, make_array(3, 6, 0, 3, -2, -2)); + TEST_REGEX_SEARCH("(foo)(\\Kbar|baz)", perl, "foobar", match_default, make_array(3, 6, 0, 3, 3, 6, -2, -2)); + TEST_REGEX_SEARCH("(foo)(\\Kbar|baz)", perl, "foobaz", match_default, make_array(0, 6, 0, 3, 3, 6, -2, -2)); + TEST_REGEX_SEARCH("(foo\\Kbar)baz", perl, "foobarbaz", match_default, make_array(3, 9, 0, 6, -2, -2)); + + // Line ending \R: + TEST_REGEX_SEARCH("\\R", perl, "foo\nbar", match_default, make_array(3, 4, -2, -2)); + TEST_REGEX_SEARCH("\\R", perl, "foo\rbar", match_default, make_array(3, 4, -2, -2)); + TEST_REGEX_SEARCH("\\R", perl, "foo\r\nbar", match_default, make_array(3, 5, -2, -2)); + // see if \u works: + const wchar_t* w = "\u2028"; + if(*w == 0x2028u) + { + TEST_REGEX_SEARCH_W(L"\\R", perl, L"foo\u2028bar", match_default, make_array(3, 4, -2, -2)); + TEST_REGEX_SEARCH_W(L"\\R", perl, L"foo\u2029bar", match_default, make_array(3, 4, -2, -2)); + } }