I need a GREP to fix a space problem in a book, I want to change the first ( - ) in the paragraph to ( -) and the second to (- ), so I should do it in two steps but the grep applies the first step to the all the ( - ).
The GREP I tried:
( - )?
Copy link to clipboard
Try the following
Find What (\( - \))(.*?)(\( - \)) Change to ( -)$2(- )
Thank you, Manan.
That did it after adjusting it to not include parentheses.
so it looks like this:
( - )(.*?)( - )
Look at the first post that @Peter Kahrel made. That should be the way to go. My method could cause issues as shown by another post by Peter. You can chain the two search replace operations into one by using the FindChangeList script shipped with InDesign and that way just a single click should do all the edits for you.
Copy link to clipboard
So you want to change English/Dutch spaced dashes to French/Spanish/etc. 'semi-spaced' dashes. Assuming that all your space dashes are those that you're after, you could try these two expressions.
The opening dashes (I used \x20 for the space character so that you can see it)
Find what: \x20-\x20(?=.+?\x20-\x20) Change to: \x20-
Then do the closing dashes:
Find what: \x20-[^\x20].+\K\x20-\x20 Change to: -\x20
@Manan Joshi -- I think the parentheses in the example are just to show the spaces before the dashes. But anyway, unfortunately, doing a replacement like you suggest makes a bash of any formatting.
Hi @Peter Kahrel, thanks for sharing your thoughts. Apart from the parentheses, I did a quick test before sharing the regex and found that changes in properties like stroke color, or font were properly preserved when the change was made using my grep search and replace. However, I do understand your point.
Well. . . Before and after:
Hi @Manan Joshi -- I've no idea why it works in your video. Are those characters outlined? Then it makes sense that it works. I tried with some other formats, and the shifts happen in every case:
Underline, bold, a colour, a condition, and a font+G stroked.
Nothing special with the text. I just used fill with palceholder text, added the local overrides and the ran the Grep find/replace. Anyhow your point is well recieved and hopefully the OP will pay heed to your suggestion.