inline.

>
> Check this out:
>
> #!/usr/bin/perl
>
> $_ = " x11x  x22x a ";
>
> #with '.*?'
> $re1 = qr/x.*?\d\dx|a/;
> ($j) = /($re1\s)?/;
> ($k) = /($re1\s){1}/;
> print "j:$j:$/";
> print "k:$k:$/";
>
>
> Gives you:
> j::
> k:x11x :
>


very helpful. i would have thought that /($re1\s)?/ would produce *something!* 
i can't believe that i've been writing regex for over 10 years and have been 
unclear about something so basic. oh well, at least i got '/($re1\s){1}/' 
right. ;.)

>
> #!/usr/bin/perl
>
> $_ = " x11x  x22x a ";
>
> #with '.*?'
> $re1 = qr/x.*?\d\dx|a/;
> ($g,$h) = /($re1\s)?($re1)/;
> print "g:$g:$/";
> print "h:$h:$/";
>
> Gives you:
> g:x11x  x22x :
> h:a:
>
> I guess I expected it to give me something like
> g::
> h:x11x :
> where the first match was the empty string and the second was the
> pattern match.

i would have thought the same. i don't u'stand yet why .*? doesn't find a 
match other than nothing. at any rate, i found a solution to my 
problem: 'qr/x[^ ]*?\d\dx|a/'. apparently this stops the regex from gobbling 
to the 2nd ']' by forbidding it to allow those intervening blanks in its 
result.


thanks for your help,

Tom Arnall



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to