| Home | Libraries | People | FAQ | More

## Function template skip

boost::xpressive::skip — Specify which characters to skip when matching a regex.

## Synopsis

    // In header: <boost/xpressive/regex_primitives.hpp>

    template<typename Skip> unspecified skip(Skip const & skip);

## Description

`skip()` instructs the regex engine to skip certain characters when matching a regex. It is most useful for writing regexes that ignore whitespace. For instance, the following specifies a regex that skips whitespace and punctuation:

     // A sentence is one or more words separated by whitespace
     // and punctuation.
     sregex word = +alpha;
     sregex sentence = skip(set[_s | punct])( +word );

The way it works in the above example is to insert `keep(*set[_s | punct])` before each primitive within the regex. A "primitive" includes terminals like strings, character sets and nested regexes. A final `*set[_s | punct]` is added to the end of the regex. The regex `sentence` specified above is equivalent to the following:

     sregex sentence = +( keep(*set[_s | punct]) >> word )
                            >> *set[_s | punct];

| Note

Skipping does not affect how nested regexes are handled because they are treated atomically. String literals are also treated atomically; that is, no skipping is done within a string literal. So `skip(_s)("this that")` is not the same as `skip(_s)("this" >> as_xpr("that"))`. The first will only match when there is only one space between "this" and "that". The second will skip any and all whitespace between "this" and "that".

Parameters:

`skip` | A regex that specifies which characters to skip.