Quote:
Originally Posted by tobybird
Interesting concept and one our forums could benefit from if the follow works as desired.
What would happen if you wanted to replace the "U" with "You" in the following sentence: "U should bring an umbrella."
Would the outcome be "You should bring an umbrella." or You shoyould bring an youmbrella."?
|
In this case we need to change a single "u" with "you". You can try this one:
/\w+u\w+/ =>"you"
\w - is any "non-word" character
Quote:
Originally Posted by Elenna
This is working nicely, thank you!
How would I have it reduce
"?!?!?!?!?" to just "?!"
I kno wmy members will 'get around' it by alternating them. :P
|
Make it like:
"/((\?\!)|(\!\?))+/" = > "?!"
It means, replace any number of "?!" or "!?" sequences by single "?!". "|" - means "or"
Small update: to prevent users from using different combinations of "!", "?" and spaces one may try something like this:
"/((\!\s*)|(\?\s*)){3,}/" => "Exclamation!"