| C-strings (1) | template <class charT, class traits> bool regex_match (const charT* s, const basic_regex<charT,traits>& rgx, regex_constants::match_flag_type flags = regex_constants::match_default); |
|---|---|
| strings (2) | template <class ST, class SA, char charT, class traits> bool regex_match (const basic_string<charT,ST,SA>& s, const basic_regex<charT,traits>& rgx, regex_constants::match_flag_type flags = regex_constants::match_default); |
| ranges (3) | template <class BidirectionalIterator, class charT, class traits> bool regex_match (BidirectionalIterator first, BidirectionalIterator last, const basic_regex<charT,traits>& rgx, regex_constants::match_flag_type flags = regex_constants::match_default); |
| with match_results (4,5,6) | template <class charT, class Alloc, class traits> bool regex_match (const charT* s, match_results<const charT*, Alloc>& m, const basic_regex<charT,traits>& rgx, regex_constants::match_flag_type flags = regex_constants::match_default);template <class ST, class SA, class Alloc, class charT, class traits> bool regex_match (const basic_string<charT,ST,SA>& s, match_results<typename basic_string<charT,ST,SA>::const_iterator,Alloc>& m, const basic_regex<charT,traits>& rgx, regex_constants::match_flag_type flags = regex_constants::match_default);template <class BidirectionalIterator, class Alloc, class charT, class traits> bool regex_match (BidirectionalIterator first, BidirectionalIterator last, match_results<BidirectionalIterator, Alloc>& m, const basic_regex<charT,traits>& rgx, regex_constants::match_flag_type flags = regex_constants::match_default); |
| C-strings (1) | template <class charT, class traits> bool regex_match (const charT* s, const basic_regex<charT,traits>& rgx, regex_constants::match_flag_type flags = regex_constants::match_default); |
|---|---|
| strings (2) | template <class ST, class SA, char charT, class traits> bool regex_match (const basic_string<charT,ST,SA>& s, const basic_regex<charT,traits>& rgx, regex_constants::match_flag_type flags = regex_constants::match_default); |
| ranges (3) | template <class BidirectionalIterator, class charT, class traits> bool regex_match (BidirectionalIterator first, BidirectionalIterator last, const basic_regex<charT,traits>& rgx, regex_constants::match_flag_type flags = regex_constants::match_default); |
| with match_results (4,5,6) | template <class charT, class Alloc, class traits> bool regex_match (const charT* s, match_results<const charT*, Alloc>& m, const basic_regex<charT,traits>& rgx, regex_constants::match_flag_type flags = regex_constants::match_default);template <class ST, class SA, class Alloc, class charT, class traits> bool regex_match (const basic_string<charT,ST,SA>& s, match_results<typename basic_string<charT,ST,SA>::const_iterator,Alloc>& m, const basic_regex<charT,traits>& rgx, regex_constants::match_flag_type flags = regex_constants::match_default);template <class BidirectionalIterator, class Alloc, class charT, class traits> bool regex_match (BidirectionalIterator first, BidirectionalIterator last, match_results<BidirectionalIterator, Alloc>& m, const basic_regex<charT,traits>& rgx, regex_constants::match_flag_type flags = regex_constants::match_default); |
| moving string (deleted) (7) | template <class ST, class SA, class Alloc, class charT, class traits> bool regex_match (const basic_string<charT,ST,SA>&&, match_results<typename basic_string<charT,ST,SA>::const_iterator,Alloc>&, const basic_regex<charT,traits>&, regex_constants::match_flag_type=regex_constants::match_default) = delete; |
| flag* | effects on match | notes |
|---|---|---|
| match_default | Default | Default matching behavior. This constant has a value of zero**. |
| match_not_bol | Not Beginning-Of-Line | The first character is not considered a beginning of line ("^" does not match). |
| match_not_eol | Not End-Of-Line | The last character is not considered an end of line ("$" does not match). |
| match_not_bow | Not Beginning-Of-Word | The escape sequence "\b" does not match as a beginning-of-word. |
| match_not_eow | Not End-Of-Word | The escape sequence "\b" does not match as an end-of-word. |
| match_any | Any match | Any match is acceptable if more than one match is possible. |
| match_not_null | Not null | Empty sequences do not match. |
| match_continuous | Continuous | The expression must match a sub-sequence that begins at the first character. Sub-sequences must begin at the first character to match. |
| match_prev_avail | Previous Available | One or more characters exist before the first one. (match_not_bol and match_not_bow are ignored) |
| format_default | Default | Same as match_default. This constant has a value of zero**. |
| format_sed | None | Ignored by this function. See regex_constants for more info. |
| format_no_copy | ||
| format_first_only |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// regex_match example
#include <iostream>
#include <string>
#include <regex>
int main ()
{
if (std::regex_match ("subject", std::regex("(sub)(.*)") ))
std::cout << "string literal matched\n";
const char cstr[] = "subject";
std::string s ("subject");
std::regex e ("(sub)(.*)");
if (std::regex_match (s,e))
std::cout << "string object matched\n";
if ( std::regex_match ( s.begin(), s.end(), e ) )
std::cout << "range matched\n";
std::cmatch cm; // same as std::match_results<const char*> cm;
std::regex_match (cstr,cm,e);
std::cout << "string literal with " << cm.size() << " matches\n";
std::smatch sm; // same as std::match_results<string::const_iterator> sm;
std::regex_match (s,sm,e);
std::cout << "string object with " << sm.size() << " matches\n";
std::regex_match ( s.cbegin(), s.cend(), sm, e);
std::cout << "range with " << sm.size() << " matches\n";
// using explicit flags:
std::regex_match ( cstr, cm, e, std::regex_constants::match_default );
std::cout << "the matches were: ";
for (unsigned i=0; i<cm.size(); ++i) {
std::cout << "[" << cm[i] << "] ";
}
std::cout << std::endl;
return 0;
}
string literal matched string object matched range matched string literal with 3 matches string object with 3 matches range with 3 matches the matches were: [subject] [sub] [ject]