| Home | Libraries | People | FAQ | More

#### Options for POSIX Extended Regular Expressions

Exactly one of the following must always be set for POSIX extended regular expressions:

Element | Standardized | Effect when set
--- | --- | ---
extended | Yes | Specifies that the grammar recognized by the regular expression engine is the same as that used by POSIX extended regular expressions in IEEE Std 1003.1-2001, Portable Operating System Interface (POSIX ), Base Definitions and Headers, Section 9, Regular Expressions (FWD.1). Refer to the POSIX extended regular expression guide for more information. In addition some perl-style escape sequences are supported (The POSIX standard specifies that only "special" characters may be escaped, all other escape sequences result in undefined behavior).
egrep | Yes | Specifies that the grammar recognized by the regular expression engine is the same as that used by POSIX utility grep when given the -E option in IEEE Std 1003.1-2001, Portable Operating System Interface (POSIX ), Shells and Utilities, Section 4, Utilities, grep (FWD.1). That is to say, the same as POSIX extended syntax, but with the newline character acting as an alternation character in addition to "|".
awk | Yes | Specifies that the grammar recognized by the regular expression engine is the same as that used by POSIX utility awk in IEEE Std 1003.1-2001, Portable Operating System Interface (POSIX ), Shells and Utilities, Section 4, awk (FWD.1). That is to say: the same as POSIX extended syntax, but with escape sequences in character classes permitted. In addition some perl-style escape sequences are supported (actually the awk syntax only requires \a \b \t \v \f \n and \r to be recognised, all other Perl-style escape sequences invoke undefined behavior according to the POSIX standard, but are in fact recognised by Boost.Regex).

The following options may also be set when using POSIX extended regular expressions:

Element | Standardized | Effect when set
--- | --- | ---
icase | Yes | Specifies that matching of regular expressions against a character container sequence shall be performed without regard to case.
nosubs | Yes | Specifies that when a regular expression is matched against a character container sequence, then no sub-expression matches are to be stored in the supplied `match_results` structure.
optimize | Yes | Specifies that the regular expression engine should pay more attention to the speed with which regular expressions are matched, and less to the speed with which regular expression objects are constructed. Otherwise it has no detectable effect on the program output. This currently has no effect for Boost.Regex.
collate | Yes | Specifies that character ranges of the form `[a-b]` should be locale sensitive. This bit is on by default for POSIX-Extended regular expressions, but can be unset to force ranges to be compared by code point only.
newline_alt | No | Specifies that the \n character has the same effect as the alternation operator |. Allows newline separated lists to be used as a list of alternatives.
no_escape_in_lists | No | When set this makes the escape character ordinary inside lists, so that `[\b]` would match either '\' or 'b'. This bit is on by default for POSIX-Extended regular expressions, but can be unset to force escapes to be recognised inside lists.
no_bk_refs | No | When set then backreferences are disabled. This bit is on by default for POSIX-Extended regular expressions, but can be unset to support for backreferences on.
no_except | No | Prevents `basic_regex` from throwing an exception when an invalid expression is encountered.
save_subexpression_location | No | When set then the locations of individual sub-expressions within the original regular expression string can be accessed via the `subexpression()` member function of `basic_regex`.