Using regex lookbehinds in C++11

c++, c++11, regex

Solution

C++11 `<regex>` uses ECMAScript's (ECMA-262) regex syntax, so it will not have look-behind (other flavors of regex that C++11 supports also don't have look-behind).

If your use case requires the use of look-behind, you may consider using Boost.Regex instead.

Problem

Why can't I use lookbehinds in C++11? Lookahead works fine. ``` std::regex e("(?<=a)b"); ``` This will throw the following exception: ``` The expression contained mismatched ( and ). ``` This wont throw any exception: ``` std::regex e("a(?=b)"); ``` What am I missing?

Original source

Related problems