Does your version of InDesign support GREP searches?
Then you don't need a script. GREP is designed to do exactly what you are describing:
Normal search with wild cards makes difficulties when replacing, because the wildards cannot be used in the replacement text.
See the online help for how to use GREP: http://help.adobe.com/en_US/indesign/cs/using/WS1952D538-1335-4b1d-BA5E-FA5A176FDC9Fa.html
Thank you very much, I know this document. But while I am rather
successful in GREP search, I am not at all successful with replace. It
always turns out different than I expect. For instance my search is:
(\d)(-)(\d). I find what I want, a minus sign between numerals. For
instance I find 1915-1917 with the middle three characters selected. I
want the minus to be replace by a n dash.
Since only field 2 ist to be changed I write $2‒ as a replacement text.
But I get: 191-‒917, not at all, what I expect. So both numerals are
deleted, the minus is still there, followed by the n dash. Is there any
tutorial on GREP replacement texts?
Re: Search with wild cards and replacing
created by <http://forums.adobe.com/people/%5BJongware%5D>
in /InDesign Scripting/ - View the full discussion
replace: $1~$2 (what is a 'n dash' ¿)
as a german guy you may have a look at gerald singelmanns intodruction to grep – google will be your friend ;-)
En-dash code is ~= but you got the rest spot on.