Sunday, December 04, 2005

Perl: difference between + and *

+ means 1 or more occurences

* means 0 or more occurences

for examples:

$str = "good food";
($str1 = $str) =~ s/o*/e;
($str2 = $str) =~ s/o+/e;

result is:
$str1: egood food
$str2: ged food

0 Comments:

Post a Comment

<< Home