in reply to Regex text extraction b/w first intance of pattern X and third instance of pattern Y.
You'll have better luck with regex if you think in terms of what you do want to match rather than what you don't want to match or what's around what you want to match.
The above can also be written asmy ($match) = $body =~ /(?<=a)([^c]*c[^c]*c[^c]*)(?=c)/;
Or maybe you wantmy ($match) = $body =~ /(?<=a)([^c]*(?:c[^c]*){2})(?=c)/;
my ($match) = $body =~ /(?<=a)([^ac]*(?:c[^ac]*){2})(?=c)/;
|
|---|