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

understanding GREP

Return to Member Forum

  • Author
    Posts
    • #1248626
      Niki Roberts
      Member

      I have a very long Glossary that was set up like this:

      Alpine—Area above the maximum elevation of any trees.

      I would like to change the glossary term (before the em dash) to semibold. I have set up a character style for the semibold. I have searched for GREP code for ‘any word’ and ‘before em dash’

      This seems like a simple GREP code. But I don’t really understand how to set it up. Can anyone help me with the code for this?

    • #1248635
      Aaron Troia
      Participant

      Niki,

      Try,

      Find: ^[^—]+

      This says “Beginning at the start of the line, find everything not an Em Dash” to find everything between the start of the line and Em Dash.

      If all your entries are one word you could do something this,

      Find: ^\w+(?=—)

      The ^\w+ might be enough but I add the lookahead assertion to make sure it is only finding words that precede an Em Dash.

      Aaron

    • #1248675
      Niki Roberts
      Member

      Hi Aaron,

      Thank you very much.

      Some of the terms have two words like this:

      advanced regeneration—In a forest ecosystem…

      When I open the find menu, I am putting ^_ in the ‘Find what:’ field. I thought there was a place for GREP code in the ‘Change Format:’ popup menu, but I can’t find it.

      Where do I put the GREP code that you gave me, so it changes the word to semibold?

    • #1248685
      Niki Roberts
      Member

      Aaron,
      I figured out that it is not in the Find/Change menu but in the Paragraph styles. Your code worked perfectly, even on the ones with two words. Thank you so much!

    • #1248695
      Aaron Troia
      Participant

      oh good! Im glad you figured it out. I did forget to mention that you could do it within search and replace it, but that it might be easier to do it within the Paragraph styles (especially for what you are doing, it’s perfect).

    • #1248715

      A Nested Style would have worked as well: “Up to”, then “1”, then “^_” — the code for an em-dash.

      Curiously enough, there could be Reasons to use a nested style over a GREP style. You can use the style applied in a nested style in a variable, to display the text in a running header.

    • #1248745
      Niki Roberts
      Member

      Theunis,
      Thanks. I never thought about nested styles. This is not something I know a lot about, but it’s worth looking into.

    • #1248755
      Becky Lipps
      Member

      I have a request, if you please :)

      What would be a search expression for removing a space before a parenthetical expression contain digits only?

      I.e.: blah. (74) *changes to* blah.(74)

      Thanks in advance.

      Nora

    • #1248775
      Aaron Troia
      Participant

      Using the GREP Find/Change window, try

      Find: (\(\d+)
      Change: $1

    • #1248785
      David Blatner
      Keymaster

      Yeah, I love grep styles, but nested styles are so much easier! :-)
      https://indesignsecrets.com/video-how-to-automate-run-in-header-styles.php

    • #1248805
      Niki Roberts
      Member

      Hi David,
      WOW! I just watched your video and YES, nested styles are much easier. Mostly, because there is no coding. As a designer of more than 20 years, I do not do code. My brain does not think that way. ?

    • #1248855
      Becky Lipps
      Member

      Thanks, Aaron! perfect. I will check out the video too.

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