0

My text in Indesign contains numerous instances of words followed by a comma and no space after the comma (like: "Hello,Joe"). I'd like to insert a space after the commas (corrected: "Hello, Joe"). I thought to use the Find/Change feature.

Using Find/Change I entered this in the Find dialog: "^$,^$". It finds the words with no space after a comma, as I had hoped. I thought entering "^$, ^$" in the Change field would preserve my text and add the space, but alls it does is change my text to "Hell^$, ^$oe."

How do I get this to work?

5
  • Have you looked at the “Found text” submenu in the “@” menu on the Find/Change dialog box? That should have what you’re looking for. – Janus Bahs Jacquet Dec 29 '15 at 21:58
  • Janus, When I select "Found Text" the Change field changes to "$0". What do I need to do with that in order for it to add a space after the comma? – JeremyH Dec 29 '15 at 22:11
  • 1
    You need to set off the text you want repeated in parentheses in the Find field, so you’ll have two groups of text: the one before the comma, and the one after the comma: (^$),(^$). $1, $2, $3 (etc.) function as placeholders in the Replace field, so you simply put them where you want the groups of text found to go in the replacement string: $1, $2. – Janus Bahs Jacquet Dec 29 '15 at 22:14
  • Thanks for that explanation! I knew I was not getting the concept of how the Find/Change works. I'll try this and see what I can do. – JeremyH Dec 29 '15 at 22:19
  • 1
    Honestly, I would cheat. Replace all the commas with comma-space, and then do another S/R for double spaces. Very quick and no variables involved. – Lauren-Clear-Monica-Ipsum Dec 30 '15 at 3:21
2

I worked out the solution thanks to Janus Bahs Jacquet's comment:

Using the GREP option in Find/Change I entered "(,)([\l\u])" in the Find field. The first set of parentheses searches for a comma and the second looks for any letter, which I used because it will not match to a whitespace.

In Change I entered ", $2" which is a comma, space to be inserted, and a placeholder ("$2") that refers to "([\l\u])" in the Find field. The placeholder keeps any letter that immediately followed the comma.

Now that I get the concept, the online documentation seems much clearer. Thanks!

3
  • 1
    You don't have to put the comma in parentheses—parentheses mark groups of text that you intend to use again in the replacement field (i.e., text that varies), and a comma is just a comma. So to make it even simpler, you could do just “,(\S)”, where \S is the escaped GREP character for ‘anything that is not a space character’, and then replace it with “, $1”. – Janus Bahs Jacquet Dec 31 '15 at 3:46
  • @JanusBahsJacquet wouldnt it be easier just to match a forward lookup and replace by , – joojaa Dec 31 '15 at 9:01
  • @joojaa I don't know about easier… equally easy, I'd say. (The reason I rarely do lookaheads and lookbehinds is that I somehow manage to forget the proper syntax in about 15 seconds, no matter how many times I look it up.) – Janus Bahs Jacquet Dec 31 '15 at 9:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.