|
Boost Users : |
From: izua (izua.richard_at_[hidden])
Date: 2007-08-21 00:00:44
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 <john <at> johnmaddock.co.uk> 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 <boost/regex.hpp>
> #include <boost/bind.hpp>
>
> using namespace std;
> using namespace boost;
>
> vector<string> preg_match_all(const string & s, const regex & expr)
> {
> typedef regex_iterator<string::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_at_[hidden]
> 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.
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net