<regex>

Defines a template class to parse TR1 Regular Expressions, and several template classes and functions to search text for matches to a regular expression object.

#include <regex>

Declarations

Class

Description

basic_regex Class

Wraps a regular expression.

match_results Class

Holds a sequence of submatches.

regex_constants Class

Holds assorted constants.

regex_error Class

Reports a bad regular expression.

regex_iterator Class

Iterates through match results.

regex_traits Class

Describes characteristics of elements for matching.

regex_traits<char> Class

Describes characteristics of char for matching.

regex_traits<wchar_t> Class

Describes characteristics of wchar_t for matching.

regex_token_iterator Class

Iterates through submatches.

sub_match Class

Describes a submatch.

Type Definitions

Type

Description

cmatch Typedef

Type definition for charmatch_results.

cregex_iterator Typedef

Type definition for charregex_iterator.

cregex_token_iterator Typedef

Type definition for charregex_token_iterator.

csub_match Typedef

Type definition for charsub_match.

regex Typedef

Type definition for charbasic_regex.

smatch Typedef

Type definition for stringmatch_results.

sregex_iterator Typedef

Type definition for stringregex_iterator.

sregex_token_iterator Typedef

Type definition for stringregex_token_iterator.

ssub_match Typedef

Type definition for stringsub_match.

wcmatch Typedef

Type definition for wchar_tmatch_results.

wcregex_iterator Typedef

Type definition for wchar_tregex_iterator.

wcregex_token_iterator Typedef

Type definition for wchar_tregex_token_iterator.

wcsub_match Typedef

Type definition for wchar_tsub_match.

wregex Typedef

Type definition for wchar_tbasic_regex.

wsmatch Typedef

Type definition for wstringmatch_results.

wsregex_iterator Typedef

Type definition for wstringregex_iterator.

wsregex_token_iterator Typedef

Type definition for wstringregex_token_iterator.

wssub_match Typedef

Type definition for wstringsub_match.

Template Functions

Function

Description

regex_match Function

Exactly matches a regular expression.

regex_replace Function

Replaces matched regular expressions.

regex_search Function

Searches for a regular expression match.

swap Function <regex>

Swaps basic_regex or match_results objects.

Operator

Description

operator== <regex>

Comparison of various objects, equal.

operator!= <regex>

Comparison of various objects, not equal.

operator< <regex>

Comparison of various objects, less than.

operator<= <regex>

Comparison of various objects, less than or equal.

operator> <regex>

Comparison of various objects, greater than.

operator>= <regex>

Comparison of various objects, greater than or equal.

operator<< <regex>

Inserts a sub_match in a stream.

Remarks

To create a regular expression object, use the template class basic_regex Class or one of its specializations, regex Typedef and wregex Typedef, together with the syntax flags of type regex_constants::syntax_option_type.

To search text for matches to a regular expression object, use the template functions regex_match Function and regex_search Function, together with the match flags of type regex_constants::match_flag_type. These functions return results by using the template class match_results Class and its specializations, cmatch Typedef, wcmatch Typedef, smatch Typedef, and wsmatch Typedef, together with the template class sub_match Class and its specializations, csub_match Typedef, wcsub_match Typedef, ssub_match Typedef, and wssub_match Typedef.

To replace text that matches a regular expression object, use the template function regex_replace Function, together with the match flags of type regex_constants::match_flag_type.

To iterate through multiple matches of a regular expression object, use the template classes regex_iterator Class and regex_token_iterator Class or one of their specializations, cregex_iterator Typedef, sregex_iterator Typedef, wcregex_iterator Typedef, wsregex_iterator Typedef, cregex_token_iterator Typedef, sregex_token_iterator Typedef, wcregex_token_iterator Typedef, or wsregex_token_iterator Typedef, together with the match flags of type regex_constants::match_flag_type.

To modify the details of the grammar of regular expressions, write a class that implements the regular expression traits.

See Also

Concepts

TR1 Regular Expressions