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 p
tom arnall am Montag, 26. Juni 2006 20:42:
[...]
> do you have any idea why:
>
> $_ = " x11x x22x a ";
>
> $re1 = qr/x.*?\d\dx|a/;
> $re2 = qr/($re1\s)?$re1/;
> ($_) = /($re2)/;
> print $_;
>
> doesn't produce 'x11x' ? (note btw that if you insert '\n' between the
> f
On Jun 26, 2006, at 11:42 AM, tom arnall wrote:
On Monday 26 June 2006 10:49 am, Peter Cornelius wrote:
...
x|a #followed by an 'x' or an 'a'
aren't the alternates (1) everything to the left of '|' and (2)
'a'? thus - to
take another example - the following:
$_='
inline
On Monday 26 June 2006 10:49 am, Peter Cornelius wrote:
> I think I can parse this regex:
>
> qr/x #match one 'x'
> .{1,4} #followed by no less than one but no more than four of
> anything
> \d\d #followed by 2 digits.
> x|a #followed by an 'x' or an
I think I can parse this regex:
qr/x #match one 'x'
.{1,4} #followed by no less than one but no more than four of
anything
\d\d #followed by 2 digits.
x|a #followed by an 'x' or an 'a'
/x;
You're string looks like
" x11x x22x a"
So if we march through
the following code:
1 #!/usr/bin/perl -w
2
3 $_ = " x11x x22x a ";
4
5 #with '.*?'
6 $re1 = qr/x.*?\d\dx|a/;
7 $re2 = qr/($re1\s)?$re1/;
8 ($f) = /($re2)/;