Quote:
Originally Posted by theducks
newbies to S&R should stay far away from Replace all's
There is an art to writing search terms that ONLY catch precisely what you want.
which won't get catalog, catastrophe...
Extra care is needed to not modify the same term OUTSIDE the <body> block
|
You wouldn't want "\s" in this case, "\s" matches any Whitespace Character. This on its face sounds reasonable if you want to catch a single word.... although it only catches " cat " with a space before+after.
You would want to use a Word Boundary, which is "\b". More information on it can be found here:
http://www.regular-expressions.info/wordboundaries.html
This would be a more accurate Regex:
Using \s would fail if you had these examples where no space is before AND after the word "cat":
Quote:
He kept on chanting, "cat jumped over the moon!"
"This was the cat's saucer."
He pushed the cat.
|
Quote:
Originally Posted by mrmikel
I had a time recently when I wanted to capitalize all the instances of ATIS, a WWII agency. I also got sATISfaction as well!
|
Same with this case, you would want:
Code:
F: \batis\b
R: ATIS
I also second everyone saying BACK UP FIRST. And I would recommend against doing a Replace All, make sure that you are Replacing these one-by-one, and just double-checking to see that everything is working as you want it. It is very easy to make a simple mistake in a Regex and really mangle your document.