开发者

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 expr开发者_开发技巧ession.

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?
     }


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜