[re.alg.match]

# 28 Text processing library [[text]](./#text)

## 28.6 Regular expressions library [[re]](re#alg.match)

### 28.6.10 Regular expression algorithms [[re.alg]](re.alg#match)

#### 28.6.10.2 regex_match [re.alg.match]

[ð](#lib:regex_match)

`template<class BidirectionalIterator, class Allocator, class charT, class traits>
  bool regex_match(BidirectionalIterator first, BidirectionalIterator last,
                   match_results<BidirectionalIterator, Allocator>& m,
                   const basic_regex<charT, traits>& e,
                   regex_constants::match_flag_type flags = regex_constants::match_default);
`

[1](#1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L11736)

*Preconditions*: BidirectionalIterator models[bidirectional_iterator](iterator.concept.bidir#concept:bidirectional_iterator "24.3.4.12 Concept bidirectional_­iterator [iterator.concept.bidir]") ([[iterator.concept.bidir]](iterator.concept.bidir "24.3.4.12 Concept bidirectional_­iterator"))[.](#1.sentence-1)

[2](#2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L11741)

*Effects*: Determines whether there is a match between the
regular expression e, and all of the character
sequence [first, last)[.](#2.sentence-1)

The parameter flags is
used to control how the expression is matched against the character
sequence[.](#2.sentence-2)

When determining if there is a match, only potential matches
that match the entire character sequence are considered[.](#2.sentence-3)

Returns true if such a match exists, false otherwise[.](#2.sentence-4)

[*Example [1](#example-1)*: std::regex re("Get|GetValue");
std::cmatch m;
regex_search("GetValue", m, re); // returns true, and m[0] contains "Get" regex_match ("GetValue", m, re); // returns true, and m[0] contains "GetValue" regex_search("GetValues", m, re); // returns true, and m[0] contains "Get" regex_match ("GetValues", m, re); // returns false â *end example*]

[3](#3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L11762)

*Postconditions*: m.ready() == true in all cases[.](#3.sentence-1)

If the function returns false, then the effect
on parameter m is unspecified except that m.size() returns 0 and m.empty() returns true[.](#3.sentence-2)

Otherwise the effects on parameter m are given in
Table [123](#tab:re.alg.match "Table 123: Effects of regex_­match algorithm")[.](#3.sentence-3)

Table [123](#tab:re.alg.match) — Effects of regex_match algorithm [[tab:re.alg.match]](./tab:re.alg.match)  

| [ð](#tab:re.alg.match-row-1)<br>**Element** | **Value** |
| --- | --- |
| [ð](#tab:re.alg.match-row-2)<br>m.size() | 1 + e.mark_count() |
| [ð](#tab:re.alg.match-row-3)<br>m.empty() | false |
| [ð](#tab:re.alg.match-row-4)<br>m.prefix().first | first |
| [ð](#tab:re.alg.match-row-5)<br>m.prefix().second | first |
| [ð](#tab:re.alg.match-row-6)<br>m.prefix().matched | false |
| [ð](#tab:re.alg.match-row-7)<br>m.suffix().first | last |
| [ð](#tab:re.alg.match-row-8)<br>m.suffix().second | last |
| [ð](#tab:re.alg.match-row-9)<br>m.suffix().matched | false |
| [ð](#tab:re.alg.match-row-10)<br>m[0].first | first |
| [ð](#tab:re.alg.match-row-11)<br>m[0].second | last |
| [ð](#tab:re.alg.match-row-12)<br>m[0].matched | true |
| [ð](#tab:re.alg.match-row-13)<br>m[n].first | For all integers 0 < n < m.size(), the start of the sequence that matched sub-expression n[.](#tab:re.alg.match-row-13-column-2-sentence-1)<br>Alternatively, if sub-expression n did not participate in the match, then last[.](#tab:re.alg.match-row-13-column-2-sentence-2) |
| [ð](#tab:re.alg.match-row-14)<br>m[n].second | For all integers 0 < n < m.size(), the end of the sequence that matched sub-expression n[.](#tab:re.alg.match-row-14-column-2-sentence-1)<br>Alternatively, if sub-expression n did not participate in the match, then last[.](#tab:re.alg.match-row-14-column-2-sentence-2) |
| [ð](#tab:re.alg.match-row-15)<br>m[n].matched | For all integers 0 < n < m.size(), true if sub-expression n participated in the match, false otherwise[.](#tab:re.alg.match-row-15-column-2-sentence-1) |

[ð](#lib:regex_match_)

`template<class BidirectionalIterator, class charT, class traits>
  bool regex_match(BidirectionalIterator first, BidirectionalIterator last,
                   const basic_regex<charT, traits>& e,
                   regex_constants::match_flag_type flags = regex_constants::match_default);
`

[4](#4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L11847)

*Effects*: Behaves âas ifâ by constructing an instance ofmatch_results<BidirectionalIterator> what, and then
returning the result ofregex_match(first, last, what, e, flags)[.](#4.sentence-1)

[ð](#lib:regex_match__)

`template<class charT, class Allocator, class traits>
  bool regex_match(const charT* str,
                   match_results<const charT*, Allocator>& m,
                   const basic_regex<charT, traits>& e,
                   regex_constants::match_flag_type flags = regex_constants::match_default);
`

[5](#5)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L11865)

*Returns*: regex_match(str, str + char_traits<charT>​::​length(str), m, e, flags)[.](#5.sentence-1)

[ð](#lib:regex_match___)

`template<class ST, class SA, class Allocator, class charT, class traits>
  bool regex_match(const basic_string<charT, ST, SA>& s,
                   match_results<typename basic_string<charT, ST, SA>::const_iterator,
                                 Allocator>& m,
                   const basic_regex<charT, traits>& e,
                   regex_constants::match_flag_type flags = regex_constants::match_default);
`

[6](#6)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L11881)

*Returns*: regex_match(s.begin(), s.end(), m, e, flags)[.](#6.sentence-1)

[ð](#lib:regex_match____)

`template<class charT, class traits>
  bool regex_match(const charT* str,
                   const basic_regex<charT, traits>& e,
                   regex_constants::match_flag_type flags = regex_constants::match_default);
`

[7](#7)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L11895)

*Returns*: regex_match(str, str + char_traits<charT>​::​length(str), e, flags)[.](#7.sentence-1)

[ð](#lib:regex_match_____)

`template<class ST, class SA, class charT, class traits>
  bool regex_match(const basic_string<charT, ST, SA>& s,
                   const basic_regex<charT, traits>& e,
                   regex_constants::match_flag_type flags = regex_constants::match_default);
`

[8](#8)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/text.tex#L11909)

*Returns*: regex_match(s.begin(), s.end(), e, flags)[.](#8.sentence-1)
