Copy link to clipboard
Copied
Hi
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:
( - )?
Try the following
Find What
(\( - \))(.*?)(\( - \))
Change to
( -)$2(- )
-Manan
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
P
Copy link to clipboard
Copied
Try the following
Find What
(\( - \))(.*?)(\( - \))
Change to
( -)$2(- )
-Manan
Copy link to clipboard
Copied
Thank you, Manan.
That did it after adjusting it to not include parentheses.
so it looks like this:
Find:
( - )(.*?)( - )
change to:
-$2-
Copy link to clipboard
Copied
Hi @AK09M,
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.
-Manan
Copy link to clipboard
Copied
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
P
Copy link to clipboard
Copied
@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.
P.
Copy link to clipboard
Copied
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.
-Manan
Copy link to clipboard
Copied
Well. . . Before and after:
Copy link to clipboard
Copied
Hi @Peter Kahrel,
See the video given below
Any idea why the formatting I used are not getting messed up.
-Manan
Copy link to clipboard
Copied
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.
P.
Copy link to clipboard
Copied
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.
-Manan