Boost logo

Boost Users :

From: Keith MacDonald (boost_at_[hidden])
Date: 2006-08-25 09:26:00


There can't be many regular expressions that would make sense when reversed,
but you can use std::reverse to reverse a literal string.

- Keith MacDonald

"david v" <danova_fr_at_[hidden]> wrote in message
news:BAY108-F20FA7B10BB1196BB7A9D7C97450_at_phx.gbl...
> Hello,
> Is it possible to reverse a regex. In my example below i'm trying to match
> the word "hope " and its reverse "epoh". Obviously i could build up a
> regex
> such as (hope|epoh) but i was wondering if there is a member in libboost
> that implements that function directly ?
>
> string re = "hope";
> boost::regex *regex = new boost::regex(re,boost::regbase::icase);
>
>
> std::string in = "hope is forward and epoh is reversed";
> boost::smatch match;
> std::string::const_iterator start = in.begin();
> std::string::const_iterator end = in.end();
>
> while (boost::regex_search(start,end,match,re,boost::match_extra))
> {
> cout << "Match:" << match[0] ;
> }
>
> Thanks,
>
> david


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