[re.regex.assign]

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

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

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

#### 28.6.7.3 Assignment [re.regex.assign]

[ð](#lib:basic_regex,operator=)

`basic_regex& operator=(const basic_regex& e);
`

[1](#1)

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

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

[ð](#lib:basic_regex,operator=_)

`basic_regex& operator=(basic_regex&& e) noexcept;
`

[2](#2)

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

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

e is in a valid state with unspecified value[.](#2.sentence-2)

[ð](#lib:basic_regex,operator=__)

`basic_regex& operator=(const charT* p);
`

[3](#3)

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

*Effects*: Equivalent to: return assign(p);

[ð](#lib:basic_regex,operator=___)

`basic_regex& operator=(initializer_list<charT> il);
`

[4](#4)

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

*Effects*: Equivalent to: return assign(il.begin(), il.end());

[ð](#lib:basic_regex,operator=____)

`template<class ST, class SA>
  basic_regex& operator=(const basic_string<charT, ST, SA>& s);
`

[5](#5)

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

*Effects*: Equivalent to: return assign(s);

[ð](#lib:basic_regex,assign)

`basic_regex& assign(const basic_regex& e);
`

[6](#6)

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

*Effects*: Equivalent to: return *this = e;

[ð](#lib:basic_regex,assign_)

`basic_regex& assign(basic_regex&& e) noexcept;
`

[7](#7)

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

*Effects*: Equivalent to: return *this = std​::​move(e);

[ð](#lib:basic_regex,assign__)

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

[8](#8)

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

*Effects*: Equivalent to: return assign(string_type(p), f);

[ð](#lib:basic_regex,assign___)

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

[9](#9)

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

*Effects*: Equivalent to: return assign(string_type(p, len), f);

[ð](#lib:basic_regex,assign____)

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

[10](#10)

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

*Effects*: Assigns the regular expression contained in the strings, interpreted according the flags specified in f[.](#10.sentence-1)

If an exception is thrown, *this is unchanged[.](#10.sentence-2)

[11](#11)

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

*Postconditions*: If no exception is thrown,flags() returns f and mark_count() returns the number of marked sub-expressions within the expression[.](#11.sentence-1)

[12](#12)

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

*Returns*: *this[.](#12.sentence-1)

[13](#13)

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

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

[ð](#lib:basic_regex,assign_____)

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

[14](#14)

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

*Effects*: Equivalent to: return assign(string_type(first, last), f);

[ð](#lib:assign,basic_regex______)

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

[15](#15)

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

*Effects*: Equivalent to: return assign(il.begin(), il.end(), f);
