---
name: "std::tr1::basic_regex"
section: "3cxx"
platform: "linux"
package: "libstdc++6-4.4-doc"
version: "4.4.5-8"
release: "Debian 6.0 (Squeeze)"
platforms: ["linux"]
url: "https://new.carta.tech/std::tr1::basic_regex"
---

# std::tr1::basic\_regex(3cxx)

## NAME

std::tr1::basic\_regex -

## SYNOPSIS

### Public Types

typedef regex\_constants::syntax\_option\_type **flag\_type**\
 typedef \_Rx\_traits::locale\_type **locale\_type**\
 typedef \_Rx\_traits::string\_type **string\_type**\
 typedef \_Ch\_type **value\_type**\

### Public Member Functions

**basic\_regex** & **assign** (const **basic\_regex** &\_\_that)\
 template\<typename \_InputIterator \> **basic\_regex** & **assign** (\_InputIterator \_\_first, \_InputIterator \_\_last, flag\_type \_\_flags=regex\_constants::ECMAScript)\
 **basic\_regex** & **assign** (**initializer\_list**\< \_Ch\_type \> \_\_l, flag\_type \_\_f=regex\_constants::ECMAScript)\
 **basic\_regex** & **assign** (const \_Ch\_type \*\_\_p, flag\_type \_\_flags=regex\_constants::ECMAScript)\
 **basic\_regex** & **assign** (const \_Ch\_type \*\_\_p, std::size\_t \_\_len, flag\_type \_\_flags)\
 template\<typename \_Ch\_typeraits , typename \_Allocator \> **basic\_regex** & **assign** (const **basic\_string**\< \_Ch\_type, \_Ch\_typeraits, \_Allocator \> &\_\_s, flag\_type \_\_f=regex\_constants::ECMAScript)\
 **basic\_regex** (const \_Ch\_type \*\_\_p, flag\_type \_\_f=regex\_constants::ECMAScript)\
 **basic\_regex** (const **basic\_regex** &\_\_rhs)\
 template\<typename \_Ch\_traits , typename \_Ch\_alloc \> **basic\_regex** (const **basic\_string**\< \_Ch\_type, \_Ch\_traits, \_Ch\_alloc \> &\_\_s, flag\_type \_\_f=regex\_constants::ECMAScript)\
 **basic\_regex** ()\
 template\<typename \_InputIterator \> **basic\_regex** (\_InputIterator \_\_first, \_InputIterator \_\_last, flag\_type \_\_f=regex\_constants::ECMAScript)\
 **basic\_regex** (const \_Ch\_type \*\_\_p, std::size\_t \_\_len, flag\_type \_\_f)\
 **basic\_regex** (**initializer\_list**\< \_Ch\_type \> \_\_l, flag\_type \_\_f=regex\_constants::ECMAScript)\
 flag\_type **flags** () const \
 locale\_type **getloc** () const \
 locale\_type **imbue** (locale\_type \_\_loc)\
 unsigned int **mark\_count** () const \
 template\<typename \_Ch\_typeraits , typename \_Allocator \> **basic\_regex** & **operator=** (const **basic\_string**\< \_Ch\_type, \_Ch\_typeraits, \_Allocator \> &\_\_s)\
 **basic\_regex** & **operator=** (const \_Ch\_type \*\_\_p)\
 **basic\_regex** & **operator=** (const **basic\_regex** &\_\_rhs)\
 void **swap** (**basic\_regex** &\_\_rhs)\
 **~basic\_regex** ()\

### Static Public Attributes

**Constants**\
\
  **tr1** \[7.8.1\] std \[28.8.1\]

static const regex\_constants::syntax\_option\_type **icase**\
 static const regex\_constants::syntax\_option\_type **nosubs**\
 static const regex\_constants::syntax\_option\_type **optimize**\
 static const regex\_constants::syntax\_option\_type **collate**\
 static const regex\_constants::syntax\_option\_type **ECMAScript**\
 static const regex\_constants::syntax\_option\_type **basic**\
 static const regex\_constants::syntax\_option\_type **extended**\
 static const regex\_constants::syntax\_option\_type **awk**\
 static const regex\_constants::syntax\_option\_type **grep**\
 static const regex\_constants::syntax\_option\_type **egrep**\

### Protected Attributes

flag\_type **\_M\_flags**\
 unsigned int **\_M\_mark\_count**\
 string\_type **\_M\_pattern**\
 \_Rx\_traits **\_M\_traits**\

## Detailed Description

### template\<typename \_Ch\_type, typename \_Rx\_traits = regex\_traits\<\_Ch\_type\>\> class std::tr1::basic\_regex\< \_Ch\_type, \_Rx\_traits \>

Objects of specializations of this class represent regular expressions constructed from sequences of character type `_Ch_type`.

Storage for the regular expression is allocated and deallocated as necessary by the member functions of this class.

Definition at line 709 of file tr1\_impl/regex.

## Constructor & Destructor Documentation

### template\<typename \_Ch\_type, typename \_Rx\_traits = regex\_traits\<\_Ch\_type\>\> std::tr1::basic\_regex\< \_Ch\_type, \_Rx\_traits \>::basic\_regex ()` [inline]` Constructs a basic regular expression that does not match any character sequence.

Definition at line 750 of file tr1\_impl/regex.

### template\<typename \_Ch\_type, typename \_Rx\_traits = regex\_traits\<\_Ch\_type\>\> std::tr1::basic\_regex\< \_Ch\_type, \_Rx\_traits \>::basic\_regex (const \_Ch\_type \* \_\_p, flag\_type \_\_f = `regex_constants::ECMAScript`)` [inline, explicit]`

Constructs a basic regular expression from the sequence \[p, p + char\_traits\<\_Ch\_type\>::length(p)) interpreted according to the flags in `f`. **Parameters:**

*p* A pointer to the start of a C-style null-terminated string containing a regular expression. \
 *f* Flags indicating the syntax rules and options.

**Exceptions:**

**regex\_error if** `p` **is not a valid regular expression.**

**Definition at line 766 of file tr1\_impl/regex.**

### template\<typename \_Ch\_type, typename \_Rx\_traits = regex\_traits\<\_Ch\_type\>\> std::tr1::basic\_regex\< \_Ch\_type, \_Rx\_traits \>::basic\_regex (const \_Ch\_type \* \_\_p, std::size\_t \_\_len, flag\_type \_\_f)` [inline]`

**Constructs a basic regular expression from the sequence \[p, p + len) interpreted according to the flags in** `f`**. Parameters:**

*p* **A pointer to the start of a string containing a regular expression.** \
 *len* **The length of the string containing the regular expression.** \
 *f* **Flags indicating the syntax rules and options.**

**Exceptions:**

**regex\_error if** `p` **is not a valid regular expression.**

**Definition at line 782 of file tr1\_impl/regex.**

### template\<typename \_Ch\_type, typename \_Rx\_traits = regex\_traits\<\_Ch\_type\>\> std::tr1::basic\_regex\< \_Ch\_type, \_Rx\_traits \>::basic\_regex (const basic\_regex\< \_Ch\_type, \_Rx\_traits \> & \_\_rhs)` [inline]`

**Copy-constructs a basic regular expression. Parameters:**

*rhs* **A** `regex` **object.**

**Definition at line 791 of file tr1\_impl/regex.**

### template\<typename \_Ch\_type, typename \_Rx\_traits = regex\_traits\<\_Ch\_type\>\> template\<typename \_Ch\_traits , typename \_Ch\_alloc \> std::tr1::basic\_regex\< \_Ch\_type, \_Rx\_traits \>::basic\_regex (const basic\_string\< \_Ch\_type, \_Ch\_traits, \_Ch\_alloc \> & \_\_s, flag\_type \_\_f = `regex_constants::ECMAScript`)` [inline, explicit]`

**Constructs a basic regular expression from the string** `s` **interpreted according to the flags in** `f`**. Parameters:**

*s* **A string containing a regular expression.** \
 *f* **Flags indicating the syntax rules and options.**

**Exceptions:**

**regex\_error if** `s` **is not a valid regular expression.**

**Definition at line 807 of file tr1\_impl/regex.**

### template\<typename \_Ch\_type, typename \_Rx\_traits = regex\_traits\<\_Ch\_type\>\> template\<typename \_InputIterator \> std::tr1::basic\_regex\< \_Ch\_type, \_Rx\_traits \>::basic\_regex (\_InputIterator \_\_first, \_InputIterator \_\_last, flag\_type \_\_f = `regex_constants::ECMAScript`)` [inline]`

**Constructs a basic regular expression from the range \[first, last) interpreted according to the flags in** `f`**. Parameters:**

*first* **The start of a range containing a valid regular expression.** \
 *last* **The end of a range containing a valid regular expression.** \
 *f* **The format flags of the regular expression.**

**Exceptions:**

**regex\_error if \[first, last) is not a valid regular expression.**

**Definition at line 826 of file tr1\_impl/regex.**

### template\<typename \_Ch\_type, typename \_Rx\_traits = regex\_traits\<\_Ch\_type\>\> std::tr1::basic\_regex\< \_Ch\_type, \_Rx\_traits \>::basic\_regex (initializer\_list\< \_Ch\_type \> \_\_l, flag\_type \_\_f = `regex_constants::ECMAScript`)` [inline]`

**Constructs a basic regular expression from an initializer list. Parameters:**

*l* **The initializer list.** \
 *f* **The format flags of the regular expression.**

**Exceptions:**

**regex\_error if** `l` **is not a valid regular expression.**

**Definition at line 840 of file tr1\_impl/regex.**

### template\<typename \_Ch\_type, typename \_Rx\_traits = regex\_traits\<\_Ch\_type\>\> std::tr1::basic\_regex\< \_Ch\_type, \_Rx\_traits \>::~basic\_regex ()` [inline]`

**Destroys a basic regular expression.**

**Definition at line 849 of file tr1\_impl/regex.**

## Member Function Documentation

### template\<typename \_Ch\_type, typename \_Rx\_traits = regex\_traits\<\_Ch\_type\>\> basic\_regex& std::tr1::basic\_regex\< \_Ch\_type, \_Rx\_traits \>::assign (const basic\_regex\< \_Ch\_type, \_Rx\_traits \> & \_\_that)` [inline]`

**the real assignment operator. Parameters:**

*that* **Another regular expression object.**

**Definition at line 888 of file tr1\_impl/regex.**

**References std::tr1::basic\_regex\< \_Ch\_type, \_Rx\_traits \>::swap().**

**Referenced by std::tr1::basic\_regex\< \_Ch\_type, \_Rx\_traits \>::operator=().**

### template\<typename \_Ch\_type, typename \_Rx\_traits = regex\_traits\<\_Ch\_type\>\> basic\_regex& std::tr1::basic\_regex\< \_Ch\_type, \_Rx\_traits \>::assign (const \_Ch\_type \* \_\_p, flag\_type \_\_flags = `regex_constants::ECMAScript`)` [inline]`

**Assigns a new regular expression to a regex object from a C-style null-terminated string containing a regular expression pattern. Parameters:**

*p* **A pointer to a C-style null-terminated string containing a regular expression pattern.** \
 *flags* **Syntax option flags.**

**Exceptions:**

**regex\_error if p does not contain a valid regular expression pattern interpreted according to** `flags`**. If regex\_error is thrown, \*this remains unchanged.**

**Definition at line 909 of file tr1\_impl/regex.**

**References std::tr1::basic\_regex\< \_Ch\_type, \_Rx\_traits \>::assign().**

**Referenced by std::tr1::basic\_regex\< \_Ch\_type, \_Rx\_traits \>::assign().**

### template\<typename \_Ch\_type, typename \_Rx\_traits = regex\_traits\<\_Ch\_type\>\> template\<typename \_InputIterator \> basic\_regex& std::tr1::basic\_regex\< \_Ch\_type, \_Rx\_traits \>::assign (\_InputIterator \_\_first, \_InputIterator \_\_last, flag\_type \_\_flags = `regex_constants::ECMAScript`)` [inline]`

**Assigns a new regular expression to a regex object. Parameters:**

*first* **The start of a range containing a valid regular expression.** \
 *last* **The end of a range containing a valid regular expression.** \
 *flags* **Syntax option flags.**

**Exceptions:**

**regex\_error if p does not contain a valid regular expression pattern interpreted according to** `flags`**. If regex\_error is thrown, the object remains unchanged.**

**Definition at line 966 of file tr1\_impl/regex.**

**References std::tr1::basic\_regex\< \_Ch\_type, \_Rx\_traits \>::assign().**

**Referenced by std::tr1::basic\_regex\< \_Ch\_type, \_Rx\_traits \>::assign().**

### template\<typename \_Ch\_type, typename \_Rx\_traits = regex\_traits\<\_Ch\_type\>\> basic\_regex& std::tr1::basic\_regex\< \_Ch\_type, \_Rx\_traits \>::assign (initializer\_list\< \_Ch\_type \> \_\_l, flag\_type \_\_f = `regex_constants::ECMAScript`)` [inline]`

**Assigns a new regular expression to a regex object. Parameters:**

*l* **An initializer list representing a regular expression.** \
 *flags* **Syntax option flags.**

**Exceptions:**

**regex\_error if** `l` **does not contain a valid regular expression pattern interpreted according to** `flags`**. If regex\_error is thrown, the object remains unchanged.**

**Definition at line 982 of file tr1\_impl/regex.**

**References std::tr1::basic\_regex\< \_Ch\_type, \_Rx\_traits \>::assign().**

**Referenced by std::tr1::basic\_regex\< \_Ch\_type, \_Rx\_traits \>::assign().**

### template\<typename \_Ch\_type, typename \_Rx\_traits = regex\_traits\<\_Ch\_type\>\> basic\_regex& std::tr1::basic\_regex\< \_Ch\_type, \_Rx\_traits \>::assign (const \_Ch\_type \* \_\_p, std::size\_t \_\_len, flag\_type \_\_flags)` [inline]`

**Assigns a new regular expression to a regex object from a C-style string containing a regular expression pattern. Parameters:**

*p* **A pointer to a C-style string containing a regular expression pattern.** \
 *len* **The length of the regular expression pattern string.** \
 *flags* **Syntax option flags.**

**Exceptions:**

**regex\_error if p does not contain a valid regular expression pattern interpreted according to** `flags`**. If regex\_error is thrown, \*this remains unchanged.**

**Definition at line 927 of file tr1\_impl/regex.**

**References std::tr1::basic\_regex\< \_Ch\_type, \_Rx\_traits \>::assign().**

**Referenced by std::tr1::basic\_regex\< \_Ch\_type, \_Rx\_traits \>::assign().**

### template\<typename \_Ch\_type, typename \_Rx\_traits = regex\_traits\<\_Ch\_type\>\> template\<typename \_Ch\_typeraits , typename \_Allocator \> basic\_regex& std::tr1::basic\_regex\< \_Ch\_type, \_Rx\_traits \>::assign (const basic\_string\< \_Ch\_type, \_Ch\_typeraits, \_Allocator \> & \_\_s, flag\_type \_\_f = `regex_constants::ECMAScript`)` [inline]`

**Assigns a new regular expression to a regex object from a string containing a regular expression pattern. Parameters:**

*s* **A string containing a regular expression pattern.** \
 *flags* **Syntax option flags.**

**Exceptions:**

**regex\_error if p does not contain a valid regular expression pattern interpreted according to** `flags`**. If regex\_error is thrown, \*this remains unchanged.**

**Definition at line 943 of file tr1\_impl/regex.**

**References std::tr1::basic\_regex\< \_Ch\_type, \_Rx\_traits \>::swap().**

### template\<typename \_Ch\_type, typename \_Rx\_traits = regex\_traits\<\_Ch\_type\>\> flag\_type std::tr1::basic\_regex\< \_Ch\_type, \_Rx\_traits \>::flags () const` [inline]`

**Gets the flags used to construct the regular expression or in the last call to assign().**

**Definition at line 1001 of file tr1\_impl/regex.**

**Referenced by std::tr1::basic\_regex\< \_Ch\_type, \_Rx\_traits \>::operator=().**

### template\<typename \_Ch\_type, typename \_Rx\_traits = regex\_traits\<\_Ch\_type\>\> locale\_type std::tr1::basic\_regex\< \_Ch\_type, \_Rx\_traits \>::getloc () const` [inline]`

**Gets the locale currently imbued in the regular expression object.**

**Definition at line 1019 of file tr1\_impl/regex.**

### template\<typename \_Ch\_type, typename \_Rx\_traits = regex\_traits\<\_Ch\_type\>\> locale\_type std::tr1::basic\_regex\< \_Ch\_type, \_Rx\_traits \>::imbue (locale\_type \_\_loc)` [inline]`

**Imbues the regular expression object with the given locale. Parameters:**

*loc* **A locale.**

**Definition at line 1011 of file tr1\_impl/regex.**

### template\<typename \_Ch\_type, typename \_Rx\_traits = regex\_traits\<\_Ch\_type\>\> unsigned int std::tr1::basic\_regex\< \_Ch\_type, \_Rx\_traits \>::mark\_count () const` [inline]`

**Gets the number of marked subexpressions within the regular expression.**

**Definition at line 993 of file tr1\_impl/regex.**

### template\<typename \_Ch\_type, typename \_Rx\_traits = regex\_traits\<\_Ch\_type\>\> template\<typename \_Ch\_typeraits , typename \_Allocator \> basic\_regex& std::tr1::basic\_regex\< \_Ch\_type, \_Rx\_traits \>::operator= (const basic\_string\< \_Ch\_type, \_Ch\_typeraits, \_Allocator \> & \_\_s)` [inline]`

**Replaces a regular expression with a new one constructed from a string. Parameters:**

*A* **pointer to a string containing a regular expression.**

**Definition at line 878 of file tr1\_impl/regex.**

**References std::tr1::basic\_regex\< \_Ch\_type, \_Rx\_traits \>::assign(), and std::tr1::basic\_regex\< \_Ch\_type, \_Rx\_traits \>::flags().**

### template\<typename \_Ch\_type, typename \_Rx\_traits = regex\_traits\<\_Ch\_type\>\> basic\_regex& std::tr1::basic\_regex\< \_Ch\_type, \_Rx\_traits \>::operator= (const \_Ch\_type \* \_\_p)` [inline]`

**Replaces a regular expression with a new one constructed from a C-style null-terminated string. Parameters:**

*A* **pointer to the start of a null-terminated C-style string containing a regular expression.**

**Definition at line 867 of file tr1\_impl/regex.**

**References std::tr1::basic\_regex\< \_Ch\_type, \_Rx\_traits \>::assign(), and std::tr1::basic\_regex\< \_Ch\_type, \_Rx\_traits \>::flags().**

### template\<typename \_Ch\_type, typename \_Rx\_traits = regex\_traits\<\_Ch\_type\>\> basic\_regex& std::tr1::basic\_regex\< \_Ch\_type, \_Rx\_traits \>::operator= (const basic\_regex\< \_Ch\_type, \_Rx\_traits \> & \_\_rhs)` [inline]`

**Assigns one regular expression to another.**

**Definition at line 856 of file tr1\_impl/regex.**

**References std::tr1::basic\_regex\< \_Ch\_type, \_Rx\_traits \>::assign().**

### template\<typename \_Ch\_type, typename \_Rx\_traits = regex\_traits\<\_Ch\_type\>\> void std::tr1::basic\_regex\< \_Ch\_type, \_Rx\_traits \>::swap (basic\_regex\< \_Ch\_type, \_Rx\_traits \> & \_\_rhs)` [inline]`

**Swaps the contents of two regular expression objects. Parameters:**

*rhs* **Another regular expression object.**

**Definition at line 1029 of file tr1\_impl/regex.**

**Referenced by std::tr1::basic\_regex\< \_Ch\_type, \_Rx\_traits \>::assign(), and std::tr1::swap().**

## Author

**Generated automatically by Doxygen for libstdc++ from the source code.**
