[re.regex.construct]

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

## 28.6 Regular expressions library [[re]](re#regex.construct)

### 28.6.7 Class template basic_regex [[re.regex]](re.regex#construct)

#### 28.6.7.2 Constructors [re.regex.construct]

[ð](#lib:basic_regex,constructor)

`basic_regex();
`

[1](#1)

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

*Postconditions*: *this does not match any character sequence[.](#1.sentence-1)

[ð](#lib:basic_regex,constructor_)

`explicit basic_regex(const charT* p, flag_type f = regex_constants::ECMAScript);
`

[2](#2)

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

*Preconditions*: [p, p + char_traits<charT>​::​length(p)) is a valid range[.](#2.sentence-1)

[3](#3)

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

*Effects*: The object's internal finite state machine
is constructed from the regular expression contained in
the sequence of characters
[p, p + char_traits<charT>​::​​length(p)), and
interpreted according to the flags f[.](#3.sentence-1)

[4](#4)

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

*Postconditions*: flags() returns f[.](#4.sentence-1)

mark_count() returns the number of marked sub-expressions
within the expression[.](#4.sentence-2)

[5](#5)

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

*Throws*: regex_error if
[p, p + char_traits<charT>​::​length(p)) is not a valid regular expression[.](#5.sentence-1)

[ð](#lib:basic_regex,constructor__)

`basic_regex(const charT* p, size_t len, flag_type f = regex_constants::ECMAScript);
`

[6](#6)

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

*Preconditions*: [p, p + len) is a valid range[.](#6.sentence-1)

[7](#7)

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

*Effects*: The object's internal finite state machine
is constructed from the regular expression contained in
the sequence of characters [p, p + len), and
interpreted according the flags specified in f[.](#7.sentence-1)

[8](#8)

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

*Postconditions*: flags() returns f[.](#8.sentence-1)

mark_count() returns the number of marked sub-expressions
within the expression[.](#8.sentence-2)

[9](#9)

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

*Throws*: regex_error if [p, p + len) is not a valid regular expression[.](#9.sentence-1)

[ð](#lib:basic_regex,constructor___)

`basic_regex(const basic_regex& e);
`

[10](#10)

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

*Postconditions*: flags() and mark_count() returne.flags() and e.mark_count(), respectively[.](#10.sentence-1)

[ð](#lib:basic_regex,constructor____)

`basic_regex(basic_regex&& e) noexcept;
`

[11](#11)

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

*Postconditions*: flags() and mark_count() return the values thate.flags() and e.mark_count(), respectively, had before construction[.](#11.sentence-1)

[ð](#lib:basic_regex,constructor_____)

`template<class ST, class SA>
  explicit basic_regex(const basic_string<charT, ST, SA>& s,
                       flag_type f = regex_constants::ECMAScript);
`

[12](#12)

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

*Effects*: The object's internal finite state machine
is constructed from the regular expression contained in
the string s, and
interpreted according to the flags specified in f[.](#12.sentence-1)

[13](#13)

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

*Postconditions*: flags() returns f[.](#13.sentence-1)

mark_count() returns the number of marked sub-expressions
within the expression[.](#13.sentence-2)

[14](#14)

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

*Throws*: regex_error if s is not a valid regular expression[.](#14.sentence-1)

[ð](#lib:basic_regex,constructor______)

`template<class ForwardIterator>
  basic_regex(ForwardIterator first, ForwardIterator last,
              flag_type f = regex_constants::ECMAScript);
`

[15](#15)

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

*Effects*: The object's internal finite state machine
is constructed from the regular expression contained in
the sequence of characters [first, last), and
interpreted according to the flags specified in f[.](#15.sentence-1)

[16](#16)

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

*Postconditions*: flags() returns f[.](#16.sentence-1)

mark_count() returns the number of marked sub-expressions
within the expression[.](#16.sentence-2)

[17](#17)

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

*Throws*: regex_error if the sequence [first, last) is not a
valid regular expression[.](#17.sentence-1)

[ð](#lib:basic_regex,constructor_______)

`basic_regex(initializer_list<charT> il, flag_type f = regex_constants::ECMAScript);
`

[18](#18)

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

*Effects*: Same as basic_regex(il.begin(), il.end(), f)[.](#18.sentence-1)
