|
Boost Users : |
From: jordi (jordil2_at_[hidden])
Date: 2005-02-14 04:22:56
Hello,
Maybe my question is a silly question but I have a recurrent problem and
maybe there is an easy solution: I need to create a lot of regex
expressions to match several Unix command outputs. Usually, my firsts
regex definitions are wrong and they don't match, so when the match
fails I would like to know where the "problem" is (more or less) in
order to change the regular expression.
For example:
Input text: "123 hello abc"
My first wrong Regex: "(\d)+\s+(\w)+\s+(\d)+"
If I try to match this input against the regex using regex_search with
the boost::match_continuous flag I only have the false value returned by
the function but it doesn't help me to know that the "123 hello" matched
the regex because the problem starts at "abc" trying to match "(\d)+".
I can simulate what I need checking subexpressions adding every
iteration a new "sub-regex" and stopping when the match fails (I do it
manually, changing the regex).
With my undefined funtion I would obtain:
- Input text:"123 hello abc"
- Latest rigth Regular expression: "(\d)+\s+(\w)+\s+" Matches: "123 hello "
- First wrong regex: "(\d)+\s+(\w)+\s+(\d)+" does not match.
-> So, "(\d)+" does not match "abc"
I understand that usually this is not as easy as I write in my simple
example because of the power of regular expressions but I think a
function like that would improve a lot the error reporting capabilities.
Is there any way to do what I need or I must to write my own check
function?
Best regards,
Jordi
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