How do I use GREP to find and replace all hyphens between numbers in an InDesign document?
I am working on a multi-language book, and I need to find and replace all hyphens with en-dashes that occur between numbers in the citations section. I need to avoid all hyphens that exist between roman letters.
If I use a GREP [0-9]-[0-9] it selects the numbers before and after the hyphen and I have to manually select the hyphen and replace it with an en-dash. This is labor intensive.
Is there a way for me to find the hyphen that exists between the numbers, but EXCLUDE the numbers themselves from being highlighted? This way I can run a the Find and Replace to change what will probably be 1000+ manual changes?
I tried using GREP [0-9]-[0-9] to find the hyphens, but then couldn’t find a way to have the find and replace keep the existing numbers.
Solution – 1
That’s what lookaheads and lookbehinds are for`
Solution – 2
If you have selected GREP, another way could be to use 2 capture groups and use those 2 groups in the replacement with an en-dash in between.