> 
> very true. noted. I always forget about the greedy factor
> 

Quick diction-alert; Greediness is something entirely different - your
braino was mistaking "*" for "+"

An example of greedy vs. non-greedy matching:

#!/usr/bin/perl
use strict;
use warnings; 

my $phrase = 'Anna would like a banana'; 

my ($greedy) = $phrase =~ /(.*)na/; 
my ($nongreedy) = $phrase =~ /(.*?)na/;


print "Greedy: $greedy \nNongreedy: $nongreedy \n";

produces the output 
Greedy: Anna would like a bana 
Nongreedy: An 


-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
        Lawrence Statton - [EMAIL PROTECTED] s/aba/c/g
Computer  software  consists of  only  two  components: ones  and
zeros, in roughly equal proportions.   All that is required is to
sort them into the correct order.

-- 
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