how to reverse a regex ?

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

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@hotmail.com> wrote in message news:BAY108-F20FA7B10BB1196BB7A9D7C97450@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
participants (2)
-
david v
-
Keith MacDonald