0

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?

Vittorio Romeo
  • 86,944
  • 30
  • 238
  • 393

1 Answers1

3

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.

Mitten.O
  • 435
  • 3
  • 10