orerockon
asked on
Find and repalce a specific word within parentheses
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"[whitespa ce]).
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.
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"[whitespa
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.
Use the space befor and after the word and as well as the replacement ampersand.
Find: and
Replace with: &
Find: and
Replace with: &
ASKER
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.
"(A) and (B) " so it is finding " and " between two sets of closed parentheses, not within one set.
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.
I will do some more experiments.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Find: (\(*)<and>(*\))
Replace: \1&\2