
Hello guys, How do i using Boost::Regex or standard C++ to get all the URLs from a given string.... For example... i want to write a function that is.... But this code doesnt work.... I am not sure how to use Boost::Regex to solve it.... size_t GetUrlsFromString(std::string const& str, std::vector<std::string>& urls) { boost::regex re("<a\\s+href=\"([\\-:\\w\\d\\.\\/]+)\">"); boost::sregex_token_iterator p(str.begin(), str.end(), re, 1); boost::sregex_token_iterator end; while (p != end) { std::string surl(p->first, p->second); urls.push_back(surl); ++p; } return urls.size(); } Thank you!!!! Tim

How do i using Boost::Regex or standard C++ to get all the URLs from a given string.... For example... i want to write a function that is....
But this code doesnt work.... I am not sure how to use Boost::Regex to solve it....
There's actually an example for just this use case in the regex_token_iterator docs (look towards the bottom): http://www.boost.org/doc/libs/1_45_0/libs/regex/doc/html/boost_regex/ref/reg... Does this give you what you need? John.
participants (2)
-
John Maddock
-
Tim Hsu