Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

<regex>

 

The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.

The latest version of this topic can be found at <regex>.

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

#include <regex>  

To create a regular expression object, use the template class basic_regex Class 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 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, wcmatch, smatch, and wsmatch, together with the template class sub_match Class 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 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, 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

basic_regexWraps a regular expression.
match_resultsHolds a sequence of submatches.
regex_constantsHolds assorted constants.
regex_errorReports a bad regular expression.
regex_iteratorIterates through match results.
regex_traitsDescribes characteristics of elements for matching.
regex_traits<char>Describes characteristics of char for matching.
regex_traits<wchar_t>Describes characteristics of wchar_t for matching.
regex_token_iteratorIterates through submatches.
sub_matchDescribes a submatch.

Type Definitions

cmatchType definition for char``match_results.
cregex_iteratorType definition for char``regex_iterator.
cregex_token_iteratorType definition for char``regex_token_iterator.
csub_matchType definition for char``sub_match.
regexType definition for char``basic_regex.
smatchType definition for string``match_results.
sregex_iteratorType definition for string``regex_iterator.
sregex_token_iteratorType definition for string``regex_token_iterator.
ssub_matchType definition for string``sub_match.
wcmatchType definition for wchar_t``match_results.
wcregex_iteratorType definition for wchar_t``regex_iterator.
wcregex_token_iteratorType definition for wchar_t``regex_token_iterator.
wcsub_matchType definition for wchar_t``sub_match.
wregexType definition for wchar_t``basic_regex.
wsmatchType definition for wstring``match_results.
wsregex_iteratorType definition for wstring``regex_iterator.
wsregex_token_iteratorType definition for wstring``regex_token_iterator.
wssub_matchType definition for wstring``sub_match.

Functions

regex_matchExactly matches a regular expression.
regex_replaceReplaces matched regular expressions.
regex_searchSearches for a regular expression match.
swapSwaps basic_regex or match_results objects.

Operators

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_match in a stream.

Regular Expressions (C++)

Show:
© 2017 Microsoft