in reply to Re^3: Match variables : Beginner in perl -- webperl
in thread Match variables : Beginner in perl
Instead, use m/"(.*?)"/, which will stop matching as soon as it can.Or, better (at least when you're going up to a single-character terminator), be more explicit about what you actually want by using a negated character class: m/"([^"]*)"/
If you want to match anything except a double-quote, tell Perl to match "anything except a double-quote" ([^"]), not "the shortest possible set of anything at all that happens to have a double-quote after it" (.*?").
Also, more pragmatically, if there's more to your regex after this part, then you could get cases where (.*?)" will still contain double-quotes in the match if that's needed to make the "more after this part" work. Because it's more explicit about not matching double-quotes, ([^"]*) will never have them in the match.
|
---|
In Section
Seekers of Perl Wisdom