According to regex101.com and an application I have called "RegExRx", this is a valid regular expression
(?<=\().*
Namely this should match everything that follows an open-parenthesis character. Here's how regex101.com analyzes this
/(?<=()./ (?<=() Positive Lookbehind - Assert that the regex below can be matched ( matches the character ( literally . matches any character (except newline) Quantifier: * Between zero and unlimited times, as many times as possible, giving back as needed [greedy]
However, this C++11 program throws
libc++abi.dylib: terminating with uncaught exception of type std::__1::regex_error: The expression contained mismatched ( and ).
This is Clang as shipped with Xcode 5.1.1.
Question: Should Clang accept this regex? How can I get a std::regex that is semantically equivalent to this one?
#include <iostream>
#include <regex>
int main(int argc, const char * argv[])
{
std::string x{ "(?<=\\().*" };
std::cout << "Here is my regex string " << x << std::endl;
std::regex{ x }; // throws
return 0;
}
Edit: My question is different from the proposed duplicate because I asked "How can I get a std::regex that is semantically equivalent to this one?" The semantically equivalent workaround was very helpfully provided by user hwnd below.