Thanks! This works, but it's not exactly what I want. The idea is to return all captures in all matches. Roman Perepelitsa-2 wrote:
John Maddock
writes: izua wrote:
How can I do a regex search that will return me all patterns for the given regular expression? Somehow like preg_match_all in PHP.
Please see my previous reply: http://article.gmane.org/gmane.comp.lib.boost.user/29880
John.
Here is an example:
#include <iterator> #include
#include using namespace std; using namespace boost;
vector<string> preg_match_all(const string & s, const regex & expr) { typedef regex_iteratorstring::const_iterator iter; vector<string> res; transform ( iter(s.begin(), s.end(), expr), iter(), back_inserter(res), bind(&iter::value_type::str, _1, 0) ); return res; }
preg_match_all("abcd123.ef56\tessn", regex("[0-9]+?[\\W]+?"));
Roman Perepelitsa.
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
-- View this message in context: http://www.nabble.com/regex_search-all-tf4292590.html#a12247983 Sent from the Boost - Users mailing list archive at Nabble.com.