Metacharacters that Turn off Greediness : Metacharacters « Regular Expression « Perl






Metacharacters that Turn off Greediness

    

# Greedy and not greedy
$_="abcdefghijklmnopqrstuvwxyz";
s/[a-z]+/XXX/;
print $_, "\n";

$_="abcdefghijklmnopqrstuvwxyz";
s/[a-z]+?/XXX/;
print $_, "\n";

   
    
    
    
  








Related examples in the same category

1.Meta-Character ASCII Values
2.Meta-Characters listing
3.Metacharacters and metasymbols
4.Metacharacters for Single Characters
5..* special-character combination tries to match as much as possible
6.The dot metacharacter
7.The dot metacharacter and the zero or more quantifier
8.Some Regular Expression Metacharacters