PDA

View Full Version : Word find and replace wildcard macro



Reillc01
09-03-2010, 05:26 AM
Hello, I am working on a macro to clean a Word doc before sending to text to speech service. I want to remove APA citations, tables, footers, and other unnecessary junk.

So far I have come to a basic understanding of wildcards, but am having trouble with the logic.

To remove APA citations, i.e. (smith, jones, smith, 2008) I have come up with the wildcard search " [(]*[)]" to remove parenthetical occurrences, but it picks up everything in parenthesis not just citations. I can figure out how to indicate that it should only select parenthetical occurrences that end in a date. Any suggestions?

Thanks in advance!

Ice-Tea-Jan
09-03-2010, 08:21 AM
Hello,

How about either of the search strings below?

[(]*, [0-9][0-9][0-9][0-9][)]

[(]*, [0-9]{4}[)]

It will pick up the numbers in the date PROVIDED this date is always 4 digits AND is preceded by a space and a comma.

If you think that there will be times when the comma is accidentally left out, you can omit the comma in the searches.

Hope this helps!
Janet

fumei
09-03-2010, 10:52 AM
Nice reply Janet.

Ice-Tea-Jan
09-03-2010, 12:04 PM
Thanks Gerry,

It is rare that I can provide help; usually the forum provides ME very (very!) valuable assistance.

Janet:thumb

Reillc01
09-04-2010, 07:16 PM
Thanks Janet. The first string was picking up way too much, until I ran the find and replace from the end to the beginning. When searching from the top, it would find any open parenthesis and select until it ran into a date followed by a close parenthesis. If the ( was not a citation, that could be a large selection of useful text. Running backwards, the search looks for a ) preceded by a date and stops at the next (.

Thanks for the help!

Ice-Tea-Jan
09-04-2010, 08:40 PM
You are correct! Running it BACKWARDS does the trick! I tested it.

Thanks -- you've made ME realize this is a good alternative when searching with wildcards!

Best of luck!
Janet:yes