in reply to Re^2: multi-line regexp
in thread multi-line regexp
I sat all day, tried to understand prasadbabu's code, then i asked for help to id-perl.
Then someone named Jacinta Richardson told me about this, and she said :
/ aaaaa # Find me aaaaa (?: # Followed by, but do not capture (?: # Group but do not capture (?! # Something which is not aaaaa . #and any char including newline ) )* # As many as possible ) /gs # Repeat the match, dots can include newlines
The first grouping is unnessary, but not a problem.
Negative look-aheads ask the regular _expression to look at the nextvalue and only include it in the match if it does not match that part of the _expression.
Thus the regular _expression finds: aaaaa\nbbbbb\nccccc\n
in its first run, stopping at the "aaaaa\n" which matches the negative look-ahead and then in its second run finds: aaaaa\nddddd\neeeee\n
That's what she said, and then i realize that Jacinta Richadson known as jarich here.
Thanks for your time Jarich, and hope this help jeanluca too
|
|---|