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"
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