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 Help!

Return to Member Forum

  • Author
    Posts
    • #99451
      Sally Ray
      Member

      Hi.
      I’m trying to amend some en dashes to hyphens in my InD doc but it can’t be a global change as I need to preserve some of them. Is anyone able to help with a grep?
      I need to change all en dashes that have a letter either side (so ignoring the ones with spaces) and change to a hyphen. This seems to work to find them [\u]–[\u] but I don’t know what to put into the ‘replace’ field.
      Thanks. Urgent as always so any help is appreciated.

    • #99455
      Aaron Troia
      Participant

      Hey Sally,

      So it looks like you want to find en dashes between ranges of upper case letters. so to keep your letters wrap them in parentheses so something like (\u)~=(\u) (“~=” is the InDesign special metacharacters for an en dash, you can also just type an en dash, it works either way) the parentheses, or capture groups as they are referred to in Regular Expressions, will save those so you can use them in the replace field. you can also just replace what I have in the parentheses with what you were searching for that worked for you. In the replace field put $1-$2, the dollar sign-number combination refers to the each capture group from the search field. This will keep the letters on each side of the en dash and then replace it with a hyphen.

      Hope that helps, let me know if you have any questions about what I said,

      Aaron

    • #99473
      Sally Ray
      Member

      Hi Aaron,

      Thanks for your reply. I’ve tried your suggestion. It only found the instances I needed by using [\u]–[\u] which is fine, it finds them… but when I replaced with $1-$2, it changed the physical content to be that (i.e. dose–response became dos$1-$2esponse).

      Am I doing something wrong? :(

      Sally

    • #99475
      Graham Park
      Member

      Sally
      You need to use Parenthesis not Square Brackets to make the GREP a Marking Subexpression
      Use
      (\u)—(\u)

      Then replace with
      $1-$2

    • #99476
      Graham Park
      Member

      Oops sorry, you need the Parenthesis outside then the Bracket to make it work.

      Find
      ([\u])—([\u])

      But If the Em Dash has any text or numbers and you want to change them all you can use
      (\S)—(\S)

      This will find an EM Dash that does not have a space either side of it
      Or even (.)—(.)

    • #99477
      Sally Ray
      Member

      Without wanting to swear with delight THANK YOU Graham. :)

      p.s. is there a difference if I want to do with just for letters or just for numbers?

    • #99478
      Graham Park
      Member

      For letters use

      ([\u])—([\u])

      For numbers use

      (\d)—(\d)

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