/a{1,5}/; # match 1-5 'a's prefer the longest. /a{1,5}?/; # match 1-5 'a's prefer the shortest. #### #!/usr/bin/perl -wT use strict; $_ = 'aaaab'; # greedily match upto 5 'a's followed by a word char print "Greedy: "; print /(a{1,5})\w/, "\n"; # non-greedily match upto 5 'a's followed by a word char print "NonGreedy: "; print /(a{1,5}?)\w/, "\n"; __END__ Greedy: aaaa NonGreedy: a