Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Defines a class template to parse Regular Expressions (C++), and several class templates and functions to search text for matches to a regular expression object.
Syntax
#include <regex>
Remarks
To create a regular expression object, use the class template basic_regex or one of its specializations, regex and wregex, 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 and regex_search, together with the match flags of type regex_constants::match_flag_type. These functions return results by using the class template match_results and its specializations, cmatch, wcmatch, smatch, and wsmatch, together with the class template sub_match and its specializations, csub_match, wcsub_match, ssub_match, and wssub_match.
To replace text that matches a regular expression object, use the template function regex_replace, together with the match flags of type regex_constants::match_flag_type.
To iterate through multiple matches of a regular expression object, use the class templates regex_iterator Class and regex_token_iterator Class or one of their specializations, cregex_iterator, sregex_iterator, wcregex_iterator, wsregex_iterator, cregex_token_iterator, sregex_token_iterator, wcregex_token_iterator, or wsregex_token_iterator, 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.
Classes
| Class | Description | 
|---|---|
| basic_regex | Wraps a regular expression. | 
| match_results | Holds a sequence of submatches. | 
| regex_constants | Holds assorted constants. | 
| regex_error | Reports a bad regular expression. | 
| regex_iterator | Iterates through match results. | 
| regex_traits | Describes characteristics of elements for matching. | 
| regex_traits<char> | Describes characteristics of charfor matching. | 
| regex_traits<wchar_t> | Describes characteristics of wchar_tfor matching. | 
| regex_token_iterator | Iterates through submatches. | 
| sub_match | Describes a submatch. | 
Type Definitions
| Name | Description | 
|---|---|
| cmatch | Type definition for charmatch_results. | 
| cregex_iterator | Type definition for charregex_iterator. | 
| cregex_token_iterator | Type definition for charregex_token_iterator. | 
| csub_match | Type definition for charsub_match. | 
| regex | Type definition for charbasic_regex. | 
| smatch | Type definition for stringmatch_results. | 
| sregex_iterator | Type definition for stringregex_iterator. | 
| sregex_token_iterator | Type definition for stringregex_token_iterator. | 
| ssub_match | Type definition for stringsub_match. | 
| wcmatch | Type definition for wchar_tmatch_results. | 
| wcregex_iterator | Type definition for wchar_tregex_iterator. | 
| wcregex_token_iterator | Type definition for wchar_tregex_token_iterator. | 
| wcsub_match | Type definition for wchar_tsub_match. | 
| wregex | Type definition for wchar_tbasic_regex. | 
| wsmatch | Type definition for wstringmatch_results. | 
| wsregex_iterator | Type definition for wstringregex_iterator. | 
| wsregex_token_iterator | Type definition for wstringregex_token_iterator. | 
| wssub_match | Type definition for wstringsub_match. | 
Functions
| Function | Description | 
|---|---|
| regex_match | Exactly matches a regular expression. | 
| regex_replace | Replaces matched regular expressions. | 
| regex_search | Searches for a regular expression match. | 
| swap | Swaps basic_regexormatch_resultsobjects. | 
Operators
| Operator | Description | 
|---|---|
| operator== | Comparison of various objects, equal. | 
| operator!= | Comparison of various objects, not equal. | 
| operator< | Comparison of various objects, less than. | 
| operator<= | Comparison of various objects, less than or equal. | 
| operator> | Comparison of various objects, greater than. | 
| operator>= | Comparison of various objects, greater than or equal. | 
| operator<< | Inserts a sub_matchin a stream. | 
See also
Regular Expressions (C++)
regex_constants Class
regex_error Class
<regex> functions
regex_iterator Class
<regex> operators
regex_token_iterator Class
regex_traits Class
<regex> typedefs