hello. I'm very new to c++ and boost. I'm trying to get the host name of a given url:
this is what I have now:
int main()
{
string url = "http://www.amazon.com/gp/product/blabla";
//Regular Expression from Javascript.
boost::regex ex("/^((\w+):\/\/\/?)?((\w+):?(\w+)?@)?([^\/\?:]+):?(\d+)?(\/?[^\?#;\|]+)?([;\|])?([^\?#]+)?\??([^#]+)?#?(\w*)/");
boost::regex_search(url, ex);
// I want it to get "http://www.amazon.com/".
}
and I get tons of errors : "unrecognized character escape sequence" I took this regex from Javascript. I'm not sure I can do that.
What is the Regular Expressions types I can use in 'Boost.regex' except Perl? Is there any kind of regex converter? (because I'm converting tons of code from Javascript to c++, and I have few more Regular Expressions).
btw, this is the function I have in Javascript:
parseHostname: function(url)
{
m = /^((\w+):\/\/\/?)?((\w+):?(\w+)?@)?([^\/\?:]+):?(\d+)?(\/?[^\?#;\|]+)?([;\|])?([^\?#]+)?\??([^#]+)?#?(\w*)/.exec(url) || [];
return m[6];
},
To see this example with PCRE and the complete code - link.