std::basic_regex - cppreference.com

##### cppreference.com

##### Search

Create account

##### Namespaces

- Page
- Discussion

##### Variants

##### Views

- View
- Edit
- History

##### Actions

# std::basic_regex

From cppreference.com
< cpp‎ | regex

Defined in header `<regex>` |  |
template < class CharT, class Traits = std::regex_traits<CharT> > class basic_regex; |  | (since C++11)

The class template `basic_regex` provides a general framework for holding regular expressions.

Several specializations for common character types are provided:

Defined in header `<regex>`
Type | Definition
`regex` | basic_regex<char>
`wregex` | basic_regex<wchar_t>

### [edit] Member types

Member type | Definition
`value_type` | CharT
`traits_type` | Traits
`string_type` | Traits::string_type
`locale_type` | Traits::locale_type
`flag_type` | std::regex_constants::syntax_option_type

### [edit] Member functions

(constructor) | constructs the regex object (public member function) [edit]
(destructor) | destructs the regex object (public member function) [edit]
operator= | assigns the contents (public member function) [edit]
assign | assigns the contents (public member function) [edit]
##### Observers
mark_count | returns the number of marked sub-expressions within the regular expression (public member function) [edit]
flags | returns the syntax flags (public member function) [edit]
##### Locale
getloc | get locale information (public member function) [edit]
imbue | set locale information (public member function) [edit]
##### Modifiers
swap | swaps the contents (public member function) [edit]
### Constants

Value | Effect(s)
`icase` | Character matching should be performed without regard to case.
`nosubs` | When performing matches, all marked sub-expressions `(expr)` are treated as non-marking sub-expressions `(?:expr)`. No matches are stored in the supplied std::regex_match structure and `mark_count()` is zero
`optimize` | Instructs the regular expression engine to make matching faster, with the potential cost of making construction slower. For example, this might mean converting a non-deterministic FSA to a deterministic FSA.
`collate` | Character ranges of the form "[a-b]" will be locale sensitive.
`ECMAScript` | Use the Modified ECMAScript regular expression grammar
`basic` | Use the basic POSIX regular expression grammar (grammar documentation).
`extended` | Use the extended POSIX regular expression grammar (grammar documentation).
`awk` | Use the regular expression grammar used by the awk utility in POSIX (grammar documentation)
`grep` | Use the regular expression grammar used by the grep utility in POSIX. This is effectively the same as the `basic` option with the addition of newline '\n' as an alternation separator.
`egrep` | Use the regular expression grammar used by the grep utility, with the -E option, in POSIX. This is effectively the same as the `extended` option with the addition of newline '\n' as an alternation separator in addtion to '|'.

At most one grammar option must be chosen out of `ECMAScript`, `basic`, `extended`, `awk`, `grep`, `egrep`. If no grammar is chosen, `ECMAScript` is assumed to be selected. The other options serve as modifiers, such that std::regex("meow", std::regex::icase) is equivalent to std::regex("meow", std::regex::ECMAScript|std::regex::icase)

The member constants in `basic_regex` are duplicates of the syntax_option_type constants defined in the namespace `std::regex_constants`.

### [edit] Non-member functions

std::swap(std::basic_regex) (C++11) | specializes the std::swap algorithm (function template) [edit]

Retrieved from "http://en.cppreference.com/mwiki/index.php?title=cpp/regex/basic_regex&oldid=72320"