| Home | Libraries | People | FAQ | More

## Struct template basic_regex

boost::xpressive::basic_regex — Class template basic_regex<> is a class for holding a compiled regular expression.

## Synopsis

    template<typename BidiIter>
    struct basic_regex {
      // types
      typedef BidiIter                            iterator_type;
      typedef iterator_value< BidiIter >::type    char_type;
      typedef std::basic_string< char_type >      string_type;
      typedef regex_constants::syntax_option_type flag_type;

      // construct/copy/destruct
      basic_regex();
      basic_regex(basic_regex< BidiIter > const &);
      template<typename Xpr> basic_regex(Xpr const &);
      basic_regex& operator=(basic_regex< BidiIter > const &);
      template<typename Xpr> basic_regex& operator=(Xpr const &);

      // public member functions
      std::size_t mark_count() const;
      regex_id_type regex_id() const;
      void swap(basic_regex< BidiIter > &) ;

      // public static functions
      static basic_regex< BidiIter >
      compile(string_type const &, flag_type = regex_constants::ECMAScript) ;
    };

## Description

### `basic_regex` construct/copy/destruct

1.     basic_regex();

   Postconditions: | regex_id() == 0 mark_count() == 0

2.     basic_regex(basic_regex< BidiIter > const & that);

   Parameters: |

   `that` | The basic_regex object to copy.

   Postconditions: | regex_id() == that.regex_id() mark_count() == that.mark_count()

3.     template<typename Xpr> basic_regex(Xpr const & xpr);

   Construct from a static regular expression.

   Parameters: |

   `xpr` | The static regular expression

   Requires: | Xpr is the type of a static regular expression.
   Postconditions: | regex_id() != 0 mark_count() >= 0

4.     basic_regex& operator=(basic_regex< BidiIter > const & that);

   Parameters: |

   `that` | The basic_regex object to copy.

   Postconditions: | regex_id() == that.regex_id() mark_count() == that.mark_count()
   Returns: | *this

5.     template<typename Xpr> basic_regex& operator=(Xpr const & xpr);

   Construct from a static regular expression.

   Parameters: |

   `xpr` | The static regular expression.

   Requires: | Xpr is the type of a static regular expression.
   Postconditions: | regex_id() != 0 mark_count() >= 0
   Returns: | *this
   Throws: | std::bad_alloc on out of memory

### `basic_regex` public member functions

1.     std::size_t mark_count() const;

   Returns the count of capturing sub-expressions in this regular expression

2.     regex_id_type regex_id() const;

   Returns a token which uniquely identifies this regular expression.

3.     void swap(basic_regex< BidiIter > & that) ;

   Swaps the contents of this basic_regex object with another.

   Parameters: |

   `that` | The other basic_regex object.

   Throws: | Will not throw.
   Notes: | This is a shallow swap that does not do reference tracking. If you embed a basic_regex object by reference in another regular expression and then swap its contents with another basic_regex object, the change will not be visible to the enclosing regular expression. It is done this way to ensure that swap() cannot throw.

### `basic_regex` public static functions

1.     static basic_regex< BidiIter >
       compile(string_type const & str,
               flag_type flags = regex_constants::ECMAScript) ;

   Factory method for building a regex object from a string. Equivalent to regex_compiler< BidiIter >().compile(str, flags);

   Parameters: |

   `flags` | Optional bitmask of type syntax_option_type to control how str is interpreted.
   `str` | The std::basic_string containing the regular expression.

| Copyright © 2003, 2004 Eric Niebler