Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
$s = "goodwood";
$s =~ s/o*/e/;
print "$s \n";
# got - 'egoodwood'
It really stuck me - since there is no match, why the 'e' got prefixed into the string? I understand that o* - can match nothing or more, but should the * quantifier be greedy and match the 'oo' in the good? Thanks.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Regex - substitute
by graff (Chancellor) on Feb 17, 2003 at 03:38 UTC | |
|
Re: Regex - substitute
by Paladin (Vicar) on Feb 17, 2003 at 03:30 UTC | |
|
Re: Regex - substitute
by Enlil (Parson) on Feb 17, 2003 at 03:33 UTC |