|
Boost Users : |
From: Yutaka Emura (yutaka_at_[hidden])
Date: 2003-02-21 13:37:39
Dr John Maddock,
Here is a test case.
int main(int argc, char* argv[])
{
boost::regex expression;
std::string asFind[5];
expression.assign("(?!foo)bar", boost::regbase::perl);
asFind[0] = "foobar";
asFind[1] = "??bar";
asFind[2] = "barfoo";
asFind[3] = "bar??";
asFind[4] = "bar";
for( int i = 0; i < 5; i++ ){
std::string s = asFind[i];
std::string::const_iterator start = s.begin();
std::string::const_iterator end = s.end();
boost::match_results<std::string::const_iterator> subexp;
if (boost::regex_search( start, end, subexp, expression,
boost::match_default)) {
printf( "%s - Found.\n", s.c_str() );
}
else {
printf( "%s - Not Found.\n", s.c_str() );
}
}
return 0;
}
The output is:
foobar - Not Found.
??bar - Not Found.
barfoo - Found.
bar?? - Found.
bar - Found.
However, all the words should be "Found".
Thank you for your time in advance.
Yutaka Emura
-----Original Message-----
> "(?!foo)bar" matches "bar" in the last three lines of the following:
>
> foobar
> ??bar
> barfoo
> bar??
> bar
>
> Why doesn't it match "bar" in all the lines?
Provided you are calling regex_search it should find a match in all the
cases, if it doesn't then please submit a test case.
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