How to Find Anything in Parentheses Using Word’s Search
I recently ran into a strange problem. I was asked to present an academic paper at a conference, and while writing fell automatically into the habit of referencing all my quotes and other citations with traditional parenthetical citations. When I went to produce the shorter copy that I would read from at the conference, I wanted to remove all those parenthetical citations — they were just clutter and I Knew I’d stumble over them while I read.
Here’s the thing: normally, I could just use the “wildcard” to search for anything inside of parentheses, like this: (*). The problem is, when you enable wildcards in Word’s search, you also enable a bunch of operators, and parentheses are among them — Word uses parentheses to group together different parts fo the search query, the same way you use them in math, e.g. 12*4+3 vs. 12*(4+3). So a search for (*) simply returned everything.
Here’s how I solved the problem:
- With wildcards disabled, I did a “find and replace”, replacing all left-parentheses “(” with an ampersand “&”.
- Then I replaced all the right-parentheses “)” with a dollar sign “$”.
- With the parentheses all turned into something unique (if I’d used dollar signs or ampersands in the paper, I’d have replaced the parentheses with carets or percent signs or any other punctuation or symbol I hadn’t used) I could enable “Use Wildcards” and search for the phrase “&*$” (without quotes).
- Because there might well be other statements in parentheses, I used “Find next” and “Replace” rather than “Replace all” to go through the paper and delete only the citations.
- Finally, I restored the parentheses by running the above find-and-replace operations backwards, turning dollar signs and ampersands back into their respective parentheses.
And that’s it. It wasn’t particularly intuitive, unless you’re deeply familiar with how wildcards work in Word, but once I grasped that the parentheses were the problem, it was a simple matter to replace them and blast them out of my paper.
And the presentation went well, though of course I found plenty of other things to stumble over, like words and my tongue…
Hi Dustin,
Depending on what version of Word you’re using, you could do this another (simpler) way. Since Word is recognizing the open brackets as part of its search expression, you need to type them in with a backslash: \(.
To find parentheticals, try using this expression:
\([^\)]*\)
I don’t have Word installed right now, but that should work. If not, try surrounding it with square brackets.
Later,
Adriano
Adriano’s way confused me, though I suppose it would work. Yours, on the other, Dustin, made perfect sense. Nice fix.
I like the way you think Dustin.
I have used similar methods, as I use different versions of MS Word, OpenOffice.org Writer, and older word processing software that can utilize “find and replace” functions, but use different expressions.
Substituting a character or group of characters that do not otherwise appear in the document and then deleting them is much easier, at least for me, than figuring out what expression to use with what software.
I also use “Find next” and “Replace” rather than “Replace all”, so that I know exactly what is being replaced.
You should probably write a macro to do the replacing and searching. But I would rather use some other software instead of Word, for example, LyX or Emacs 🙂
Hey, thanks….I was about to write a simple Java program to accomplish the task before finding your advice.
No, no, no. That takes way too much work. Adriano was on the right track.
To search for everything in parenthesis, type this in the search box:
\(*\)
In other words, put a slash in front of the parenthesis
As Dustin noted, the parenthesis have a special meaning when wildcards are turned on. The \ tells Word to ignore that special meaning.
Thanks, Tom.
Works perfectly in Word 2003!
This was great! I needed to find a missing close parenthesis (which I knew about by counting them by doing a search and replace of an open paren with itself and a close paren with itself, and noting that they differed by one). So I did this search and highlighted them, then only had to scroll down and look for a long streak of highlighting. (Note, though, if you close the Search pane or make any other marks on your document, the highlighting disappears.) Thanks!
I often need a quick way to remove bracketed material from text. For reasons I can’t explain, this wildcard search —
\[*\]
doesn’t work. But if I first convert that end bracket into another character (I like the tilde ~), I can use —
\[*\~
and it works fine.