Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of boost. Click here for the latest Boost documentation.
PrevUpHomeNext

Function template split_regex

boost::algorithm::split_regex — Split regex algorithm.

Synopsis

// In header: <boost/algorithm/string/regex.hpp>


template<typename SequenceSequenceT, typename RangeT, typename CharT, 
         typename RegexTraitsT> 
  SequenceSequenceT & 
  split_regex(SequenceSequenceT & Result, const RangeT & Input, 
              const basic_regex< CharT, RegexTraitsT > & Rx, 
              match_flag_type Flags = match_default);

Description

Tokenize expression. This function is equivalent to C strtok. Input sequence is split into tokens, separated by separators. Separator is an every match of the given regex. Each part is copied and added as a new element to the output container. Thus the result container must be able to hold copies of the matches (in a compatible structure like std::string) or a reference to it (e.g. using the iterator range class). Examples of such a container are std::vector<std::string> or std::list<boost::iterator_range<std::string::iterator>>

[Note] Note

Prior content of the result will be overwritten.

[Note] Note

This function provides the strong exception-safety guarantee

Parameters:

Flags

Regex options

Input

A container which will be searched.

Result

A container that can hold copies of references to the substrings.

Rx

A regular expression

Returns:

A reference to the result


PrevUpHomeNext