I'm trying to use c++ std::regex
to validate a URL. Using an abbreviated form of John Gruber's web URL matching regex documented here (I just shortened the list of TLDs it will accept), std::regex()
throws an exception with code 0x0e (which I believe is a syntax error)
std::regex myRegEx(R"((?i)\b((?:https?:(?:/{1,3}|[a-z0-9%])|[a-z0-9.\-]+[.](?:com|net|org|edu|gov|mil)\b/?(?!@))))")
Note I'm using a c++11 raw string to avoid the need to escape the backslashes.
I'm guessing the c++ regex engine expects a different syntax than what John's expression uses, but I don't know enough to figure out how to adapt it.
What can I do to make this regular expression work with std::regex
?