Abruzzo Forte e Gentile
Abruzzo Forte e Gentile

Reputation: 14869

how to understand what part of the boost::regex failed to match/search

I am using boost::regex to match (better to say boost::regex_search) a text vs a regular expression.

This one doesn't match and my regex is really huge.

Do you know if in the library is there any function telling me which part of the regex failed to match?

I am using LINUX/gcc

     std::string text; // whatever
     boost::regex rgx( "(\\w+) (\\d+) (\\s+)" );
     boost::smatch m;
     if( !boost::regex_search( text, m, rgx ) ){
         // how to know where (\\w+) or (\\d+) or (\\s+) failed?
     }

Upvotes: 2

Views: 229

Answers (2)

Shlublu
Shlublu

Reputation: 11027

There is no tool for that in the library to my knowledge, but I was using Boost version 1.28.0.

Did you try to execute (\w+), (\d+) and (\s+) independantly of each other? At least one of them should fail matching.

Upvotes: 1

Josh
Josh

Reputation: 6473

Grab kiki asap. It's an invaluable tool for testing and playing with regex.
If you are using a debian based distro, it should be in the base repositories.

Upvotes: 0

Related Questions