regex - Perl - regular expressions first occurrence of group -
i matching line against pattern, like:
if (/.*someregexp(.*)someotherregexp.*/) { process $1 } but, problem have, in line, many occurrences of "someregexp(.*)someotherregexp"
can please tell me how can select, sure!, first occurrence?
thank you!
you need make quantifiers not greedy. * greedy default, means tries capture as possible. make not greedy, add ?:
if (/.*?someregexp(.*?)someotherregexp.*?/) { process $1 }
Comments
Post a Comment