Mirco Wahab <[EMAIL PROTECTED]> writes:
> sub print_message {
> if (/^track="(.+?)"/ ){ print "Your track is $1\n" }
> ...
>
> which has a "more complicated" regex that is usually
> not understood easily by newbies.
Specially the non-greedy part. :-) I don't believe that non-greedyness would
be adequate here since I believe he's willing to process the whole line.
===========================================================================
$line = "track='My favorite track'";
if ($line =~ /^track=(.+?)/) { print "My track is $1\n"};
===========================================================================
outputs
===========================================================================
My track is '
===========================================================================
While
===========================================================================
$line = "track='My favorite track'";
if ($line =~ /^track=(.+)/) { print "My track is $1\n"};
===========================================================================
outputs
===========================================================================
My track is 'My favorite track'
===========================================================================
and what I'd use
===========================================================================
$line = "track='My favorite track'";
if ($line =~ /^track=(.*)/) { print "My track is $1\n"};
===========================================================================
has the same output. ;-)
All this running perl 5.8.8.
Be seeing you,
--
Jorge Godoy <[EMAIL PROTECTED]>
--
http://mail.python.org/mailman/listinfo/python-list