Subclause | Header | ||
Requirements | |||
Constants | <regex> | ||
Exception type | |||
Traits | |||
Regular expression template | |||
Submatches | |||
Match results | |||
Algorithms | |||
Iterators | |||
Grammar |
typename X::char_type
typename X::string_type
typename X::locale_type
typename X::char_class_type
X::length(p)
v.translate(c)
v.translate_nocase(c)
v.transform(F1, F2)
v.transform_primary(F1, F2)
v.lookup_collatename(F1, F2)
v.lookup_classname(F1, F2, b)
v.isctype(c, cl)
v.value(c, I)
u.imbue(loc)
v.getloc()
Element | Effect(s) if set | |
icase | Specifies that matching of regular expressions against a character
container sequence shall be performed without regard to case. | |
nosubs | Specifies that no sub-expressions shall be considered to be marked, so that
when a regular expression is matched against a
character container sequence, no sub-expression matches shall be
stored in the supplied match_results object. | |
optimize | ||
collate | ||
ECMAScript | Specifies that the grammar recognized by the regular expression engine
shall be that used by ECMAScript in ECMA-262, as modified in [re.grammar]. | |
basic | Specifies that the grammar recognized by the regular expression engine
shall be that used by basic regular expressions in POSIX. See also: POSIX, Base Definitions and Headers, Section 9.3 | |
extended | Specifies that the grammar recognized by the regular expression engine
shall be that used by extended regular expressions in POSIX. See also: POSIX, Base Definitions and Headers, Section 9.4 | |
awk | Specifies that the grammar recognized by the regular expression engine
shall be that used by the utility awk in POSIX. | |
grep | Specifies that the grammar recognized by the regular expression engine
shall be that used by the utility grep in POSIX. | |
egrep | Specifies that the grammar recognized by the regular expression engine
shall be that used by the utility grep when given the -E
option in POSIX. | |
multiline | Specifies that ^ shall match the beginning of a line and
$ shall match the end of a line,
if the ECMAScript engine is selected. |
Element | Effect(s) if set | |
The first character in the sequence [first, last) shall be treated
as though it is not at the beginning of a line, so the character
^ in the regular expression shall not match [first, first). | ||
The last character in the sequence [first, last) shall be treated
as though it is not at the end of a line, so the character
"$" in the regular expression shall not match [last, last). | ||
If more than one match is possible then any match is an
acceptable result. | ||
The expression shall not match an empty
sequence. | ||
The expression shall only match a sub-sequence that begins at
first. | ||
When a regular expression match is to be replaced by a
new string, the new string shall be constructed using the rules used by
the ECMAScript replace function in ECMA-262,
part 15.5.4.11 String.prototype.replace. In
addition, during search and replace operations all non-overlapping
occurrences of the regular expression shall be located and replaced, and
sections of the input that did not match the expression shall be copied
unchanged to the output string. | ||
When a regular expression match is to be replaced by a
new string, the new string shall be constructed using the rules used by
the sed utility in POSIX. | ||
During a search and replace operation, sections of
the character container sequence being searched that do not match the
regular expression shall not be copied to the output string. | ||
When specified during a search and replace operation, only the
first occurrence of the regular expression shall be replaced. |
Value | Error condition | |
error_collate | The expression contains an invalid collating element name. | |
error_ctype | The expression contains an invalid character class name. | |
error_escape | The expression contains an invalid escaped character, or a trailing
escape. | |
error_backref | The expression contains an invalid back reference. | |
error_brack | ||
error_paren | ||
error_brace | The expression contains mismatched { and } | |
error_badbrace | The expression contains an invalid range in a {} expression. | |
error_range | The expression contains an invalid character range, such as
[b-a] in most encodings. | |
error_space | There is insufficient memory to convert the expression into a finite
state machine. | |
error_badrepeat | One of *?+{ is not preceded by a valid regular expression. | |
error_complexity | The complexity of an attempted match against a regular expression
exceeds a pre-set level. | |
error_stack | There is insufficient memory to determine whether the regular
expression matches the specified character sequence. |
regex_error(regex_constants::error_type ecode);
regex_constants::error_type code() const;
using char_class_type = bitmask_type;
static size_t length(const char_type* p);
charT translate(charT c) const;
charT translate_nocase(charT c) const;
template<class ForwardIterator>
string_type transform(ForwardIterator first, ForwardIterator last) const;
template<class ForwardIterator>
string_type transform_primary(ForwardIterator first, ForwardIterator last) const;
template<class ForwardIterator>
string_type lookup_collatename(ForwardIterator first, ForwardIterator last) const;
template<class ForwardIterator>
char_class_type lookup_classname(
ForwardIterator first, ForwardIterator last, bool icase = false) const;
bool isctype(charT c, char_class_type f) const;
int value(charT ch, int radix) const;
locale_type imbue(locale_type loc);
locale_type getloc() const;
Narrow character name | Wide character name | Corresponding ctype_base::mask value | |
"alnum" | L"alnum" | ctype_base::alnum | |
"alpha" | L"alpha" | ctype_base::alpha | |
"blank" | L"blank" | ctype_base::blank | |
"cntrl" | L"cntrl" | ctype_base::cntrl | |
"digit" | L"digit" | ctype_base::digit | |
"d" | L"d" | ctype_base::digit | |
"graph" | L"graph" | ctype_base::graph | |
"lower" | L"lower" | ctype_base::lower | |
"print" | L"print" | ctype_base::print | |
"punct" | L"punct" | ctype_base::punct | |
"space" | L"space" | ctype_base::space | |
"s" | L"s" | ctype_base::space | |
"upper" | L"upper" | ctype_base::upper | |
"w" | L"w" | ctype_base::alnum | |
"xdigit" | L"xdigit" | ctype_base::xdigit |
basic_regex();
explicit basic_regex(const charT* p, flag_type f = regex_constants::ECMAScript);
basic_regex(const charT* p, size_t len, flag_type f = regex_constants::ECMAScript);
basic_regex(const basic_regex& e);
basic_regex(basic_regex&& e) noexcept;
template<class ST, class SA>
explicit basic_regex(const basic_string<charT, ST, SA>& s,
flag_type f = regex_constants::ECMAScript);
template<class ForwardIterator>
basic_regex(ForwardIterator first, ForwardIterator last,
flag_type f = regex_constants::ECMAScript);
basic_regex(initializer_list<charT> il, flag_type f = regex_constants::ECMAScript);
basic_regex& operator=(const basic_regex& e);
basic_regex& operator=(basic_regex&& e) noexcept;
basic_regex& operator=(const charT* p);
basic_regex& operator=(initializer_list<charT> il);
template<class ST, class SA>
basic_regex& operator=(const basic_string<charT, ST, SA>& s);
basic_regex& assign(const basic_regex& e);
basic_regex& assign(basic_regex&& e) noexcept;
basic_regex& assign(const charT* p, flag_type f = regex_constants::ECMAScript);
basic_regex& assign(const charT* p, size_t len, flag_type f = regex_constants::ECMAScript);
template<class ST, class SA>
basic_regex& assign(const basic_string<charT, ST, SA>& s,
flag_type f = regex_constants::ECMAScript);
template<class InputIterator>
basic_regex& assign(InputIterator first, InputIterator last,
flag_type f = regex_constants::ECMAScript);
basic_regex& assign(initializer_list<charT> il,
flag_type f = regex_constants::ECMAScript);
unsigned mark_count() const;
flag_type flags() const;
constexpr sub_match();
difference_type length() const;
operator string_type() const;
string_type str() const;
int compare(const sub_match& s) const;
int compare(const string_type& s) const;
int compare(const value_type* s) const;
void swap(sub_match& s) noexcept(see below);
template<class BiIter>
bool operator==(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);
template<class BiIter>
auto operator<=>(const sub_match<BiIter>& lhs, const sub_match<BiIter>& rhs);
template<class BiIter, class ST, class SA>
bool operator==(
const sub_match<BiIter>& lhs,
const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& rhs);
template<class BiIter, class ST, class SA>
auto operator<=>(
const sub_match<BiIter>& lhs,
const basic_string<typename iterator_traits<BiIter>::value_type, ST, SA>& rhs);
template<class BiIter>
bool operator==(const sub_match<BiIter>& lhs,
const typename iterator_traits<BiIter>::value_type* rhs);
template<class BiIter>
auto operator<=>(const sub_match<BiIter>& lhs,
const typename iterator_traits<BiIter>::value_type* rhs);
template<class BiIter>
bool operator==(const sub_match<BiIter>& lhs,
const typename iterator_traits<BiIter>::value_type& rhs);
template<class BiIter>
auto operator<=>(const sub_match<BiIter>& lhs,
const typename iterator_traits<BiIter>::value_type& rhs);
template<class charT, class ST, class BiIter>
basic_ostream<charT, ST>&
operator<<(basic_ostream<charT, ST>& os, const sub_match<BiIter>& m);
explicit match_results(const Allocator& a);
match_results(const match_results& m);
match_results(const match_results& m, const Allocator& a);
match_results(match_results&& m) noexcept;
match_results(match_results&& m, const Allocator& a);
match_results& operator=(const match_results& m);
match_results& operator=(match_results&& m);
Element | Value | |
ready() | m.ready() | |
size() | m.size() | |
str(n) | m.str(n) for all non-negative integers n < m.size() | |
prefix() | m.prefix() | |
suffix() | m.suffix() | |
(*this)[n] | m[n] for all non-negative integers n < m.size() | |
length(n) | m.length(n) for all non-negative integers n < m.size() | |
position(n) | m.position(n) for all non-negative integers n < m.size() |
bool ready() const;
size_type size() const;
size_type max_size() const;
bool empty() const;
difference_type length(size_type sub = 0) const;
difference_type position(size_type sub = 0) const;
string_type str(size_type sub = 0) const;
const_reference operator[](size_type n) const;
const_reference prefix() const;
const_reference suffix() const;
const_iterator begin() const;
const_iterator cbegin() const;
const_iterator end() const;
const_iterator cend() const;
template<class OutputIter>
OutputIter format(
OutputIter out,
const char_type* fmt_first, const char_type* fmt_last,
regex_constants::match_flag_type flags = regex_constants::format_default) const;
template<class OutputIter, class ST, class SA>
OutputIter format(
OutputIter out,
const basic_string<char_type, ST, SA>& fmt,
regex_constants::match_flag_type flags = regex_constants::format_default) const;
template<class ST, class SA>
basic_string<char_type, ST, SA> format(
const basic_string<char_type, ST, SA>& fmt,
regex_constants::match_flag_type flags = regex_constants::format_default) const;
string_type format(
const char_type* fmt,
regex_constants::match_flag_type flags = regex_constants::format_default) const;
allocator_type get_allocator() const;
void swap(match_results& that);
template<class BidirectionalIterator, class Allocator>
void swap(match_results<BidirectionalIterator, Allocator>& m1,
match_results<BidirectionalIterator, Allocator>& m2);
template<class BidirectionalIterator, class Allocator>
bool operator==(const match_results<BidirectionalIterator, Allocator>& m1,
const match_results<BidirectionalIterator, Allocator>& m2);
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);
Element | Value | |
m.size() | 1 + e.mark_count() | |
m.empty() | false | |
m.prefix().first | first | |
m.prefix().second | first | |
m.prefix().matched | false | |
m.suffix().first | last | |
m.suffix().second | last | |
m.suffix().matched | false | |
m[0].first | first | |
m[0].second | last | |
m[0].matched | true | |
m[n].first | ||
m[n].second | ||
m[n].matched | For all integers 0 < n < m.size(), true if sub-expression n participated in
the match, false otherwise. |
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);
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);
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);
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);
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);
template<class BidirectionalIterator, class Allocator, class charT, class traits>
bool regex_search(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);
Element | Value | |
m.size() | 1 + e.mark_count() | |
m.empty() | false | |
m.prefix().first | first | |
m.prefix().second | m[0].first | |
m.prefix().matched | m.prefix().first != m.prefix().second | |
m.suffix().first | m[0].second | |
m.suffix().second | last | |
m.suffix().matched | m.suffix().first != m.suffix().second | |
m[0].first | The start of the sequence of characters that matched the regular expression | |
m[0].second | The end of the sequence of characters that matched the regular expression | |
m[0].matched | true | |
m[n].first | ||
m[n].second | ||
m[n].matched | For all integers 0 < n < m.size(), true if sub-expression n
participated in the match, false otherwise. |
template<class charT, class Allocator, class traits>
bool regex_search(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);
template<class ST, class SA, class Allocator, class charT, class traits>
bool regex_search(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);
template<class BidirectionalIterator, class charT, class traits>
bool regex_search(BidirectionalIterator first, BidirectionalIterator last,
const basic_regex<charT, traits>& e,
regex_constants::match_flag_type flags = regex_constants::match_default);
template<class charT, class traits>
bool regex_search(const charT* str,
const basic_regex<charT, traits>& e,
regex_constants::match_flag_type flags = regex_constants::match_default);
template<class ST, class SA, class charT, class traits>
bool regex_search(const basic_string<charT, ST, SA>& s,
const basic_regex<charT, traits>& e,
regex_constants::match_flag_type flags = regex_constants::match_default);
template<class OutputIterator, class BidirectionalIterator,
class traits, class charT, class ST, class SA>
OutputIterator
regex_replace(OutputIterator out,
BidirectionalIterator first, BidirectionalIterator last,
const basic_regex<charT, traits>& e,
const basic_string<charT, ST, SA>& fmt,
regex_constants::match_flag_type flags = regex_constants::match_default);
template<class OutputIterator, class BidirectionalIterator, class traits, class charT>
OutputIterator
regex_replace(OutputIterator out,
BidirectionalIterator first, BidirectionalIterator last,
const basic_regex<charT, traits>& e,
const charT* fmt,
regex_constants::match_flag_type flags = regex_constants::match_default);
template<class traits, class charT, class ST, class SA, class FST, class FSA>
basic_string<charT, ST, SA>
regex_replace(const basic_string<charT, ST, SA>& s,
const basic_regex<charT, traits>& e,
const basic_string<charT, FST, FSA>& fmt,
regex_constants::match_flag_type flags = regex_constants::match_default);
template<class traits, class charT, class ST, class SA>
basic_string<charT, ST, SA>
regex_replace(const basic_string<charT, ST, SA>& s,
const basic_regex<charT, traits>& e,
const charT* fmt,
regex_constants::match_flag_type flags = regex_constants::match_default);
template<class traits, class charT, class ST, class SA>
basic_string<charT>
regex_replace(const charT* s,
const basic_regex<charT, traits>& e,
const basic_string<charT, ST, SA>& fmt,
regex_constants::match_flag_type flags = regex_constants::match_default);
template<class traits, class charT>
basic_string<charT>
regex_replace(const charT* s,
const basic_regex<charT, traits>& e,
const charT* fmt,
regex_constants::match_flag_type flags = regex_constants::match_default);
regex_iterator();
regex_iterator(BidirectionalIterator a, BidirectionalIterator b,
const regex_type& re,
regex_constants::match_flag_type m = regex_constants::match_default);
bool operator==(const regex_iterator& right) const;
const value_type& operator*() const;
const value_type* operator->() const;
regex_iterator& operator++();
regex_iterator operator++(int);
regex_token_iterator();
regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
const regex_type& re,
int submatch = 0,
regex_constants::match_flag_type m = regex_constants::match_default);
regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
const regex_type& re,
const vector<int>& submatches,
regex_constants::match_flag_type m = regex_constants::match_default);
regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
const regex_type& re,
initializer_list<int> submatches,
regex_constants::match_flag_type m = regex_constants::match_default);
template<size_t N>
regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b,
const regex_type& re,
const int (&submatches)[N],
regex_constants::match_flag_type m = regex_constants::match_default);
bool operator==(const regex_token_iterator& right) const;
const value_type& operator*() const;
const value_type* operator->() const;
regex_token_iterator& operator++();
regex_token_iterator& operator++(int);