Boost.Regex

sub_match

Synopsis

Regular expressions are different from many simple pattern-matching algorithms
in that as well as finding an overall match they can also produce
sub-expression matches: each sub-expression being delimited in the pattern by a
pair of parenthesis (...). There has to be some method for reporting
sub-expression matches back to the user: this is achieved this by defining a
class match_results that acts as an
indexed collection of sub-expression matches, each sub-expression match being
contained in an object of type sub_match
.

Objects of type sub_match may only obtained by subscripting an object
of type match_results
.

Objects of type sub_match may be compared to objects of type std::basic_string,
or const charT* or const charT
.

Objects of type sub_match may be added to objects of type std::basic_string,
or const charT* or const charT, to produce a new std::basic_string
object.

When the marked sub-expression denoted by an object of type sub_match<>
participated in a regular expression match then member matched evaluates
to true, and members first and second denote the
range of characters [first,second) which formed that match.
Otherwise matched is false, and members first and second
contained undefined values.

When the marked sub-expression denoted by an object of type sub_match<>
was repeated, then the sub_match object represents the match obtained by the
last repeat. The complete set of all the captures obtained for all the
repeats, may be accessed via the captures() member function (Note: this has
serious performance implications, you have to explicitly enable this feature).

If an object of type sub_match<> represents sub-expression 0
- that is to say the whole match - then member matched is always
true, unless a partial match was obtained as a result of the flag match_partial
being passed to a regular expression algorithm, in which case member matched
is false, and members first and second represent the
character range that formed the partial match.

Defines an implementation-specific type that satisfies the requirements of
a standard library Sequence (21.1.1 including the optional Table 68
operations), whose value_type is a sub_match<BidirectionalIterator>. This
type happens to be std::vector<sub_match<BidirectionalIterator> >,
but you shouldn't actually rely on that.