in reply to Matching 'words' in a string based on a suffix
The regexp you are looking for is:
~s/\w+ing\b/pudding/gfor which japhy's YAPE::Regexp-Explain] gives the following explanation (reformated):
The regular expression: /\w+ing\b/ matches as follows: NODE EXPLANATION ==== =========== \w+ word characters (a-z, A-Z, 0-9, _) (1 or more times) ing 'ing' \b the boundary between a word char (\w) and something that is not a word char
If you want strings like f***ing to be replaced use \S (matches anything but a space) instead of \W.
Your regexp does not compile, I guess you wanted to write something like /\S+ing/ which matches anything that's not spaces then ing but then strings like derringer (ing in the middle of the string) would be matched.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Matching 'words' in a string based on a suffix
by magnus (Pilgrim) on Feb 07, 2001 at 15:52 UTC | |
by magnus (Pilgrim) on Feb 07, 2001 at 16:03 UTC |