Function template skip

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

Synopsis

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:

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:

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".