InDesign Wildcard Search and Replace of Text

I need to have the ability to perform and find and change in InDesign CS that does the following:
Find any letter followed by a quote (inch) mark (not smart/curly quote)
In Indesign this is accomplished by typing: ^$"
Then, Change the non-smart quote/inch mark to a proper end quote curly mark: ^}
In Indesgin this can’t be accomplished… the wild card formula “^?” replaces the real character with the formula.

I’ve been able to write the applescript to do the F&C but was wondering if someone has figured out a way around thise “wildcard” issue.

Not really sure why InDesign allows you to search for wildcards but you can’t replace using them.

I am dealing with a very similar issue right now krdzine so I think I can offer you a solution.

I overcame this by first setting any found text’s underline overprint property to true (underline overprint: true) during the first run. This causes no text changes but flags the found text. Then I’d do another search for straight quotes with the underline overprint property set to true and change them to curly quotes. Then do a 3rd search for anything with the underline overprint property set to true & change them back to false.

I believe the underline overprint property’s default value is false and not likely to be set by a user so its very unlikely you will encounter a situation where it is already true. This makes it a good choice for flagging stuff when you need to use wildcards as part of a search & replace.

Hope this helps.
LenZ

If you are looking to fix end quotes try searching for the quote and a space rather than a wild card and the quote. This would filter out beginign quotes because they would be space quote character.

I’ve tried what you suggested manually Jerome (albeit quite some time ago) & found that it misses often.

Granted I’m not 100% certain what krdzine1’s needs are but if they are anything like what I encounter when it comes to using quotes as inch indicators, hunting for a space after a quote doesn’t work in all cases where punctuation of some sort follows the quote [eg. 1". , 4"“5"), etc. ]. I think it may also fail when a return, thin, en or em space or simply nothing follows the quote. Lastly, the presence of a straight quote doesnt necessarily mean it is an inch indicator if all quotes in the document are straight quotes… only those where a number precedes it would qualify (although it is possible that a number followed by a quote might not be a reference to inches).

Then again, after re-reading krdzine1’s post I just realized that he is looking for a letter followed by a quote so I think maybe I misunderstood what he was looking for & the above observations may be irrelevant.

Len :confused:

I did something similar to your suggestion. I searched for quotes that followed directly behind numbers and followed by a space… here is the snippet I used. It works pretty well. I sometimes miss some or tag some text with a “false” character style but in general it works well. I have a series of Find/Replaces that are scripted and run together… some turn all the trademark and registered symbols to superscript, insert non-breaking hyphens in product/part numbers, etc.

		--tag all measurements
		try
			set myssstyle to character style "Measurements"
		on error
			set myssstyle to (make character style with properties {name:"Measurements"})
		end try
		display dialog "Script is now tagging all measurements with the proper character style. Please Wait." giving up after 2 with dialog
		set myfoundcharacter to search for "^9\"^w" with change attributes {applied character style:myssstyle} -- any number followed by a quote and space
		set myfoundcharacter to search for "^9\"^p" with change attributes {applied character style:myssstyle} -- any number followed by a quote and paragraph
		set myfoundcharacter to search for "^9\"^t" with change attributes {applied character style:myssstyle} -- any number followed by a quote and tab
		set myfoundcharacter to search for "^9\"^s" with change attributes {applied character style:myssstyle} -- any number followed by a quote and non-breaking space
		set myfoundcharacter to search for "^9\")" with change attributes {applied character style:myssstyle} -- any number followed by a quote and parentheses
		set myfoundcharacter to search for "^9^}^w" with change attributes {applied character style:myssstyle} -- any number followed by a quote and space
		set myfoundcharacter to search for "^9^}^p" with change attributes {applied character style:myssstyle} -- any number followed by a quote and paragraph
		set myfoundcharacter to search for "^9^}^t" with change attributes {applied character style:myssstyle} -- any number followed by a quote and tab
		set myfoundcharacter to search for "^9^}^s" with change attributes {applied character style:myssstyle} -- any number followed by a quote and non-breaking space
		set myfoundcharacter to search for "^9^})" with change attributes {applied character style:myssstyle} -- any number followed by a quote and parentheses
		
		--change all opening quotes
		display dialog "Script is now changing all quotes to typographer's quotes. Please Wait." giving up after 2 with dialog
		set typographers quotes of text preferences to true
		set myfoundcharacter to search for " \"" with find attributes {applied character style:"Quotes"} replacing with " "" with change attributes {applied character style:"Quotes"}
		set myfoundcharacter to search for "^p\"" with find attributes {applied character style:"Quotes"} replacing with "^p"" with change attributes {applied character style:"Quotes"}
		set myfoundcharacter to search for "^t\"" with find attributes {applied character style:"Quotes"} replacing with "^t"" with change attributes {applied character style:"Quotes"}
		
		--change all closing quotes
		set myfoundcharacter to search for "\" " with find attributes {applied character style:"Quotes"} replacing with "" " with change attributes {applied character style:"Quotes"}
		set myfoundcharacter to search for "\"^p" with find attributes {applied character style:"Quotes"} replacing with ""^p" with change attributes {applied character style:"Quotes"}
		set myfoundcharacter to search for "\"^t" with find attributes {applied character style:"Quotes"} replacing with ""^t" with change attributes {applied character style:"Quotes"}
		set myfoundcharacter to search for "\"^s" with find attributes {applied character style:"Quotes"} replacing with ""^s" with change attributes {applied character style:"Quotes"}
		
		--change all inch marks
		display dialog "Script is now changing all measurements to inch marks. Please Wait." giving up after 2 with dialog
		set typographers quotes of text preferences to false
		set myfoundcharacter to search for "\"" with find attributes {applied character style:"Measurements"} replacing with "\"" with change attributes {applied character style:"Measurements"} -- any quote tagged as measurements
		set myfoundcharacter to search for "^}" with find attributes {applied character style:"Measurements"} replacing with "\"" with change attributes {applied character style:"Measurements"} -- any quote tagged as measurements
		
	end tell