in reply to Multiple regex matches in single string
I'm not sure if this is just a toy example or not, but if this is part of real project you might consider processing the string one line at a time using a state-machine pattern. That will allow you to parse it more robustly, e.g. find unmatched start and end lines, handle nested start-end blocks, print more meaningful error messages, etc.
|
---|