List Info

Thread: Re: Re: Regex - repeating a pattern within two anchors?




Re: Re: Regex - repeating a pattern within two anchors?
country flaguser name
United States
1969-12-31 18:00:00


>&gt;>>&gt; "hooyar66" == hooyar66 < pcbcad%40hotpop.com">pcbcadhotpop.com> writes:

This is dangerous:

hooyar66> $line =~ /"(.+)"/;

because if it *doesn't* match, then:

hooyar66&gt; my $str = $1;

the $1 there is the *previous* $1. Bad. Very bad idea.

NEVER use $1 except in a context where you have validated that the
match has actually succeeded.

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<; merlyn%40stonehenge.com">merlynstonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

__._,_.___
.

__,_._,___
[1]

about | contact  Other archives ( Real Estate discussion Medical topics )