[re.const]

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

## 28.6 Regular expressions library [[re]](re#const)

### 28.6.4 Namespace std​::​regex_constants [re.const]

#### [28.6.4.1](#general) General [[re.const.general]](re.const.general)

[1](#general-1)

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

The namespace std​::​regex_constants holds
symbolic constants used by the regular expression library[.](#general-1.sentence-1)

This
namespace provides three types, syntax_option_type,match_flag_type, and error_type, along with several
constants of these types[.](#general-1.sentence-2)

#### [28.6.4.2](#re.synopt) Bitmask type syntax_option_type [[re.synopt]](re.synopt)

[ð](#lib:syntax_option_type)

namespace std::regex_constants {using syntax_option_type = *T1*; inline constexpr syntax_option_type icase = *unspecified*; inline constexpr syntax_option_type nosubs = *unspecified*; inline constexpr syntax_option_type optimize = *unspecified*; inline constexpr syntax_option_type collate = *unspecified*; inline constexpr syntax_option_type ECMAScript = *unspecified*; inline constexpr syntax_option_type basic = *unspecified*; inline constexpr syntax_option_type extended = *unspecified*; inline constexpr syntax_option_type awk = *unspecified*; inline constexpr syntax_option_type grep = *unspecified*; inline constexpr syntax_option_type egrep = *unspecified*; inline constexpr syntax_option_type multiline = *unspecified*;}

[1](#re.synopt-1)

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

The type syntax_option_type is an implementation-defined bitmask
type ([[bitmask.types]](bitmask.types "16.3.3.3.3 Bitmask types"))[.](#re.synopt-1.sentence-1)

Setting its elements has the effects listed in
Table [118](#tab:re.synopt "Table 118: syntax_­option_­type effects")[.](#re.synopt-1.sentence-2)

A valid value of typesyntax_option_type shall have at most one of the grammar elementsECMAScript, basic, extended, awk, grep, egrep, set[.](#re.synopt-1.sentence-3)

If no grammar element is set, the default grammar is ECMAScript[.](#re.synopt-1.sentence-4)

Table [118](#tab:re.synopt) — syntax_option_type effects [[tab:re.synopt]](./tab:re.synopt)  

| [ð](#tab:re.synopt-row-1)<br>**Element** | **Effect(s) if set** |
| --- | --- |
| [ð](#tab:re.synopt-row-2)<br>icase | Specifies that matching of regular expressions against a character container sequence shall be performed without regard to case[.](#tab:re.synopt-row-2-column-2-sentence-1) |
| [ð](#tab:re.synopt-row-3)<br>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[.](#tab:re.synopt-row-3-column-2-sentence-1) |
| [ð](#tab:re.synopt-row-4)<br>optimize | Specifies that the regular expression engine should pay more attention to the speed with which regular expressions are matched, and less to the speed with which regular expression objects are constructed[.](#tab:re.synopt-row-4-column-2-sentence-1)<br>Otherwise it has no detectable effect on the program output[.](#tab:re.synopt-row-4-column-2-sentence-2) |
| [ð](#tab:re.synopt-row-5)<br>collate | Specifies that character ranges of the form "[a-b]" shall be locale sensitive[.](#tab:re.synopt-row-5-column-2-sentence-1) |
| [ð](#tab:re.synopt-row-6)<br>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]](re.grammar "28.6.12 Modified ECMAScript regular expression grammar")[.](#tab:re.synopt-row-6-column-2-sentence-1)<br>   See also: ECMA-262 15.10 |
| [ð](#tab:re.synopt-row-7)<br>basic | Specifies that the grammar recognized by the regular expression engine shall be that used by basic regular expressions in POSIX[.](#tab:re.synopt-row-7-column-2-sentence-1)   See also: POSIX, Base Definitions and Headers, Section 9.3 |
| [ð](#tab:re.synopt-row-8)<br>extended | Specifies that the grammar recognized by the regular expression engine shall be that used by extended regular expressions in POSIX[.](#tab:re.synopt-row-8-column-2-sentence-1)   See also: POSIX, Base Definitions and Headers, Section 9.4 |
| [ð](#tab:re.synopt-row-9)<br>awk | Specifies that the grammar recognized by the regular expression engine shall be that used by the utility awk in POSIX[.](#tab:re.synopt-row-9-column-2-sentence-1) |
| [ð](#tab:re.synopt-row-10)<br>grep | Specifies that the grammar recognized by the regular expression engine shall be that used by the utility grep in POSIX[.](#tab:re.synopt-row-10-column-2-sentence-1) |
| [ð](#tab:re.synopt-row-11)<br>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[.](#tab:re.synopt-row-11-column-2-sentence-1) |
| [ð](#tab:re.synopt-row-12)<br>multiline | Specifies that ^ shall match the beginning of a line and $ shall match the end of a line, if the ECMAScript engine is selected[.](#tab:re.synopt-row-12-column-2-sentence-1) |

#### [28.6.4.3](#re.matchflag) Bitmask type match_flag_type [[re.matchflag]](re.matchflag)

[ð](#lib:match_flag_type)

namespace std::regex_constants {using match_flag_type = *T2*; inline constexpr match_flag_type match_default = {}; inline constexpr match_flag_type match_not_bol = *unspecified*; inline constexpr match_flag_type match_not_eol = *unspecified*; inline constexpr match_flag_type match_not_bow = *unspecified*; inline constexpr match_flag_type match_not_eow = *unspecified*; inline constexpr match_flag_type match_any = *unspecified*; inline constexpr match_flag_type match_not_null = *unspecified*; inline constexpr match_flag_type match_continuous = *unspecified*; inline constexpr match_flag_type match_prev_avail = *unspecified*; inline constexpr match_flag_type format_default = {}; inline constexpr match_flag_type format_sed = *unspecified*; inline constexpr match_flag_type format_no_copy = *unspecified*; inline constexpr match_flag_type format_first_only = *unspecified*;}

[1](#re.matchflag-1)

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

The type match_flag_type is animplementation-defined bitmask type ([[bitmask.types]](bitmask.types "16.3.3.3.3 Bitmask types"))[.](#re.matchflag-1.sentence-1)

The constants of that type, except for match_default andformat_default, are bitmask elements[.](#re.matchflag-1.sentence-2)

The match_default andformat_default constants are empty bitmasks[.](#re.matchflag-1.sentence-3)

Matching a regular expression against a sequence of characters
[first, last) proceeds according to the rules of the grammar specified for the regular
expression object, modified according to the effects listed in Table [119](#tab:re.matchflag "Table 119: regex_­constants​::​match_­flag_­type effects") for
any bitmask elements set[.](#re.matchflag-1.sentence-4)

Table [119](#tab:re.matchflag) — regex_constants​::​match_flag_type effects [[tab:re.matchflag]](./tab:re.matchflag)  

| [ð](#tab:re.matchflag-row-1)<br>**Element** | **Effect(s) if set** |
| --- | --- |
| [ð](#tab:re.matchflag-row-2)<br>match_not_bol | 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)[.](#tab:re.matchflag-row-2-column-2-sentence-1) |
| [ð](#tab:re.matchflag-row-3)<br>match_not_eol | 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)[.](#tab:re.matchflag-row-3-column-2-sentence-1) |
| [ð](#tab:re.matchflag-row-4)<br>match_not_bow | The expression `"\\b"` shall not match the sub-sequence [first, first)[.](#tab:re.matchflag-row-4-column-2-sentence-1) |
| [ð](#tab:re.matchflag-row-5)<br>match_not_eow | The expression `"\\b"` shall not match the sub-sequence [last, last)[.](#tab:re.matchflag-row-5-column-2-sentence-1) |
| [ð](#tab:re.matchflag-row-6)<br>match_any | If more than one match is possible then any match is an acceptable result[.](#tab:re.matchflag-row-6-column-2-sentence-1) |
| [ð](#tab:re.matchflag-row-7)<br>match_not_null | The expression shall not match an empty sequence[.](#tab:re.matchflag-row-7-column-2-sentence-1) |
| [ð](#tab:re.matchflag-row-8)<br>match_continuous | The expression shall only match a sub-sequence that begins at first[.](#tab:re.matchflag-row-8-column-2-sentence-1) |
| [ð](#tab:re.matchflag-row-9)<br>match_prev_avail | `--first` is a valid iterator position[.](#tab:re.matchflag-row-9-column-2-sentence-1)<br>When this flag is set the flags match_not_bol and match_not_bow shall be ignored by the regular expression algorithms ([[re.alg]](re.alg "28.6.10 Regular expression algorithms")) and iterators ([[re.iter]](re.iter "28.6.11 Regular expression iterators"))[.](#tab:re.matchflag-row-9-column-2-sentence-2) |
| [ð](#tab:re.matchflag-row-10)<br>format_default | 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[.](#tab:re.matchflag-row-10-column-2-sentence-1)<br>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[.](#tab:re.matchflag-row-10-column-2-sentence-2) |
| [ð](#tab:re.matchflag-row-11)<br>format_sed | 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[.](#tab:re.matchflag-row-11-column-2-sentence-1) |
| [ð](#tab:re.matchflag-row-12)<br>format_no_copy | 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[.](#tab:re.matchflag-row-12-column-2-sentence-1) |
| [ð](#tab:re.matchflag-row-13)<br>format_first_only | When specified during a search and replace operation, only the first occurrence of the regular expression shall be replaced[.](#tab:re.matchflag-row-13-column-2-sentence-1) |

#### [28.6.4.4](#re.err) Implementation-defined error_type [[re.err]](re.err)

[ð](#lib:error_type)

namespace std::regex_constants {using error_type = *T3*; inline constexpr error_type error_collate = *unspecified*; inline constexpr error_type error_ctype = *unspecified*; inline constexpr error_type error_escape = *unspecified*; inline constexpr error_type error_backref = *unspecified*; inline constexpr error_type error_brack = *unspecified*; inline constexpr error_type error_paren = *unspecified*; inline constexpr error_type error_brace = *unspecified*; inline constexpr error_type error_badbrace = *unspecified*; inline constexpr error_type error_range = *unspecified*; inline constexpr error_type error_space = *unspecified*; inline constexpr error_type error_badrepeat = *unspecified*; inline constexpr error_type error_complexity = *unspecified*; inline constexpr error_type error_stack = *unspecified*;}

[1](#re.err-1)

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

The type error_type is an implementation-defined enumerated type ([[enumerated.types]](enumerated.types "16.3.3.3.2 Enumerated types"))[.](#re.err-1.sentence-1)

Values of type error_type represent the error
conditions described in Table [120](#tab:re.err "Table 120: error_­type values in the C locale"):

Table [120](#tab:re.err) — error_type values in the C locale [[tab:re.err]](./tab:re.err)  

| [ð](#tab:re.err-row-1)<br>**Value** | **Error condition** |
| --- | --- |
| [ð](#tab:re.err-row-2)<br>error_collate | The expression contains an invalid collating element name[.](#tab:re.err-row-2-column-2-sentence-1) |
| [ð](#tab:re.err-row-3)<br>error_ctype | The expression contains an invalid character class name[.](#tab:re.err-row-3-column-2-sentence-1) |
| [ð](#tab:re.err-row-4)<br>error_escape | The expression contains an invalid escaped character, or a trailing escape[.](#tab:re.err-row-4-column-2-sentence-1) |
| [ð](#tab:re.err-row-5)<br>error_backref | The expression contains an invalid back reference[.](#tab:re.err-row-5-column-2-sentence-1) |
| [ð](#tab:re.err-row-6)<br>error_brack | The expression contains mismatched `[` and `]`[.](#tab:re.err-row-6-column-2-sentence-1) |
| [ð](#tab:re.err-row-7)<br>error_paren | The expression contains mismatched `(` and `)`[.](#tab:re.err-row-7-column-2-sentence-1) |
| [ð](#tab:re.err-row-8)<br>error_brace | The expression contains mismatched `{` and `}`[.](#tab:re.err-row-8-column-2-sentence-1) |
| [ð](#tab:re.err-row-9)<br>error_badbrace | The expression contains an invalid range in a `{}` expression[.](#tab:re.err-row-9-column-2-sentence-1) |
| [ð](#tab:re.err-row-10)<br>error_range | The expression contains an invalid character range, such as `[b-a]` in most encodings[.](#tab:re.err-row-10-column-2-sentence-1) |
| [ð](#tab:re.err-row-11)<br>error_space | There is insufficient memory to convert the expression into a finite state machine[.](#tab:re.err-row-11-column-2-sentence-1) |
| [ð](#tab:re.err-row-12)<br>error_badrepeat | One of `*?+{` is not preceded by a valid regular expression[.](#tab:re.err-row-12-column-2-sentence-1) |
| [ð](#tab:re.err-row-13)<br>error_complexity | The complexity of an attempted match against a regular expression exceeds a pre-set level[.](#tab:re.err-row-13-column-2-sentence-1) |
| [ð](#tab:re.err-row-14)<br>error_stack | There is insufficient memory to determine whether the regular expression matches the specified character sequence[.](#tab:re.err-row-14-column-2-sentence-1) |
