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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With