Back

If your email is not recognized and you believe it should be, please contact us.

  • You must be logged in to reply to this topic.Login

GREP and found text

Return to Member Forum

  • Author
    Posts
    • #61818
      Louise Krohn
      Member

      Can anyone tell me what is going on here!

      I have a whole bunch of text that looks like this “15,16”, i.e. it's one or two digits followed by a comma followed by one or two more digits. I need to find a way of adding a space after the comma.

      I have no problem finding the strings, by using find: [,][1-09], but I can't get the replace to work. I believe it should be: [$1]~.[$2] ([found text 1: the comma] + punctuation space + [found text 2: the digit], but instead of returning the found text, it replaces it with “$1” and “$2”, i.e. “15$1space$26”.

      Help!

    • #61820

      Louise, you're almost there. But the $1 and $2 have a crucially important limitation (actually, a feature): they only get “set” to a Found Text value for Find items that are bracketed with round parentheses. That way you can be very selective about what found text you re-use in the Replace With text. Try this Find What:

      (d,)(d)

      and replace with your own “$1 space $2″.

      The first “found text”, to be stored into $1, will be any digit followed by a comma; the second set, $2, will contain the digit after that comma. When replacing, ID writes back digit #1 and comma, then the extra space you inserted into the Replace field, then digit #2. The parentheses themselves do not influence the search text at all.

      I am using “d” above to look for any single digit. So this will find any digit-comma-any digit; it doesn't matter if there are more digits before or after each of these.

      Using your parentheses correctly to mark the to-be-copied text is important, because suppose you want to find that comma but replace it with a semi-colon. In that case, you would not include the comma inside, but use “(d),(d)” instead and add the semicolon with “$1; $2″.

      You can also do other stuff, such as exchange the order of found items — look for “Second name, First Name” and replace with “First name Second name”, for example. And it's even possible to re-use the “found text” immediately in the Find Text field! This is done with a slightly different syntax, you need to use “1″, “2″ (etc.) instead of “$1″, “$2″. Try this one for fun: search for “(bw+) 1″ — it will magically find double words!

    • #61822
      Louise Krohn
      Member

      It worked like magic! There were 87 replacements to be made (this text was generated by my genealogy software and for some reason did not put the necessary commas), so I am most grateful. Thank you very much.

Viewing 2 reply threads
  • The forum ‘General InDesign Topics (CLOSED)’ is closed to new topics and replies.
Forum Ads