A greedy quantifier : Greedy « Regular Expression « Perl






A greedy quantifier

    

$string="this is a test. this is another test";

$string =~ s/is.*/is not/;
print "$string\n";

# Turning off greed
$string="this is a test. this is another test";
$string =~ s/is.*?/is not/;
print "$string\n";

   
    
    
    
  








Related examples in the same category

1.Greedy Matches
2.Greedy and non-greedy quantifiers
3.Greedy searches
4.The Greedy Metacharacters
5.The greedy quantifier
6.Turning Off Greediness
7.Shortcut Expansion Description
8.Shortcuts for Regular Expressions
9.Shortest possible match