in reply to Re: Puzzled by regex
in thread Puzzled by regex
The difference lies only in what is matched, and this is relevant only if this part is captured
Well ... the regex does capture that part but afaics, when both regexes match they both match the same thing.
Do you have an example that demonstrates this difference ?
Just to be clear - I can see that /\S+?/ and /\S+/ could conceivably match differently, but I don't see how /__\S+?__\n/ and /__\S+__\n/ can match differently.
(And it's important to me that I do understand how they match differently if, indeed, they can.)
In case I'm guilty of not presenting the full picture, the regex (it's a split) as it appears in Inline.pm is actually:
Rob
Well ... the regex does capture that part but afaics, when both regexes match they both match the same thing.
Do you have an example that demonstrates this difference ?
Just to be clear - I can see that /\S+?/ and /\S+/ could conceivably match differently, but I don't see how /__\S+?__\n/ and /__\S+__\n/ can match differently.
(And it's important to me that I do understand how they match differently if, indeed, they can.)
In case I'm guilty of not presenting the full picture, the regex (it's a split) as it appears in Inline.pm is actually:
Cheers,@{$DATA{$pkg}} = split /(?m)(__\S+?__\n)/, $data;
Rob
In Section
Seekers of Perl Wisdom