Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Help monks! I am writing a CGI script that takes user input and spits out silly things. One thing I can't seem to do correctly is substitute for any 'word' in my string that has a suffix, like -ly, or -ing.
my $example = "He is eating. She is running. They are playing in the bowl."
how can I use regular expressions to change $example to say:
"He is pudding. She is pudding. They are pudding in the bowl."
I thought that something like
$example =~ s/\s.*+ing/pudding/g;
would do it, but it's not working. What am I doing wrong?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Matching 'words' in a string based on a suffix
by mirod (Canon) on Feb 07, 2001 at 12:51 UTC | |
by magnus (Pilgrim) on Feb 07, 2001 at 15:52 UTC | |
by magnus (Pilgrim) on Feb 07, 2001 at 16:03 UTC | |
|
Re: Matching 'words' in a string based on a suffix
by mr.nick (Chaplain) on Feb 07, 2001 at 19:30 UTC |