We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

Find and repalce a specific word within parentheses

orerockon
orerockon asked
on
Medium Priority
292 Views
Last Modified: 2012-08-13
I need to replace a specific word within closed parentheses in MS word 2010 with another word. I can find any character within parentheses using wildcards in FR : \(*\)

Then, what I need to do is find exactly the word "and" and replace it with an ampersand character "&". Not the string "and" but the specific word "and", which is always preceded by and followed with one or more words (in other words, is always [single space]"and"[single space] (or more generally [whitespace]"and"[whitespace]).

Also, the expression \( and \) doesn't work since it find all instances of the pattern whether or not it is between closed parentheses, if that makes any sense. \(*[ and ]*\) selects the entire phrase, e.g., "(you and I)", not just the word "and".

Sorry, I don't know how "storage zone" was selected, I meant the question to only be in MS Word.

Comment
Watch Question

GrahamSkanRetired
CERTIFIED EXPERT
Top Expert 2012

Commented:
With 'Use wildcards' ticked, try

Find:  (\(*)<and>(*\))

Replace: \1&\2

Commented:
Use the space befor and after the word and as well as the replacement ampersand.

Find: and
Replace with: & 

Author

Commented:
Graham: It works, but it doesn't find only " and " within closed parentheses: "( and )". For example, it also finds:

"(A) and (B) " so it is finding " and " between two sets of closed parentheses, not within one set.
GrahamSkanRetired
CERTIFIED EXPERT
Top Expert 2012

Commented:
Wildcard Finds cannot always be guaranteed not to find spurious examples. It is often a matter of tuning to the best fit.

I will do some more experiments.
Retired
CERTIFIED EXPERT
Top Expert 2012
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.