Vittorio Romeo
Vittorio Romeo

Reputation: 93324

C++11 regex_error - why? (code: 2)

Why does this C++11 code throw a regex_error?

string s{R"((http)(s)?(:\/\/)(www\.)?([^ ]*))"};
regex r{s}; // throws regex_error

I've been looking all over the internet for correct escaping and I've tried multiple combinations, but I think my escaping is correct. What am I doing wrong?

Upvotes: 0

Views: 590

Answers (1)

Mitten.O
Mitten.O

Reputation: 745

GCC apparently does not really support regular expressions yet.
See the status page: http://gcc.gnu.org/onlinedocs/libstdc++/manual/status.html

As suggested by comments, you may be best off using boost for now. Clang with libc++ already has regexes too.

Upvotes: 3

Related Questions