Raindog wrote:
Hello,
I have the following regex:
sregex sig_re = "@rem {" >>(sig_= -*_)>> "}, " >> (vbp_= -*_) >> _ln;
which I am trying to use to match the last line of the following string. The string is read in from a file.
xcopy "foo" "foo3.bat" /Y xcopy "foo" "foo3.bat" /Y xcopy "foo" "foo3.bat" /Y xcopy "foo" "foo3.bat" /Y @rem c:\foo\somefile.txt files: 4 @rem {0xffffffff, SOMETYPEDEF, ""}, //c:\foo\somefile.txt
When I call:
sregex_iterator cur(file_contents.begin(), file_contents.end(), sig_re);
however, I get an assertion:
Assertion failed: !s0.matched, file c:\code\boost-trunk\boost\xpressive\detail\core\matcher\end_matcher.hpp, line 37
Originally I had wanted to match the varying parts of the above file but I kept getting the above assertion, so I decided to take the easy way and just match the last line of the file, but still got the assertion. My original regex was this:
mark_tag file_(0), vbp_(1), sig_(2); sregex files_re = "xcopy" >> *_ >> "/Y" >> _n; sregex vbp_re = "@rem " >> -*_ >> " files: " >> repeat<1, 4>(_d) >> _ln; sregex sig_re = "@rem {" >> -*_>> "}, " >> -*_ >> _ln; sregex file_re = (file_=(files_re)) >> (vbp_=(vbp_re)) >> (sig_=(sig_re));
But that failed. Which leads me to my second question, with the above file, I would like an xpressive regex that will match the 3 portions of the file so that I have:
a. An array of sub_match containing the following 4 strings xcopy "foo" "foo3.bat" /Y xcopy "foo" "foo3.bat" /Y xcopy "foo" "foo3.bat" /Y xcopy "foo" "foo3.bat" /Y
b. A sub_match with the following string:
So I did a bit more digging and the following gives me everything I want except for the capture group where I capture the list of 4 xcopy lines. sregex files_re = "xcopy" >> -*_ >> "/Y" >> _n; sregex vbp_re = "@rem " >> -*_ >> " files: " >> repeat<1, 4>(_d) >> _ln; sregex sig_re = "@rem {" >> -*_>> "}, " >> -*_ >> _ln; sregex file_re = *files_re >> (vbp_=vbp_re) >> (sig_=sig_re); Which lets me complete my immediate task but still leaves me curious about how I would go about capturing the 4 xcopy lines. Thanks, Josh