View Single Post
Old 08-20-2014, 05:57 PM   #6
Tex2002ans
Wizard
Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.Tex2002ans ought to be getting tired of karma fortunes by now.
 
Posts: 2,306
Karma: 13057279
Join Date: Jul 2012
Device: Kobo Forma, Nook
Quote:
Originally Posted by theducks View Post
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.
Code:
F: \scat\s
R: dog
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:

Code:
F: \bcat\b
R: dog
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 View Post
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.

Last edited by Tex2002ans; 08-20-2014 at 06:06 PM.
Tex2002ans is offline   Reply With Quote