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: Lookahead question

Return to Member Forum

  • Author
    Posts
    • #87540
      AaronA
      Participant

      My aim is to change manually typed bullets (+ space) to bulleted paragraph styles.

      I’ve GREP’d it fine for changing all such paragraphs to a given style. But I also need to apply a different style to the last paragraph in each bulleted list (that style has a higher Space After setting).

      I figured I’d use a negative lookahead that looks for a paragraph start followed by a bullet character. I.e., if that’s found, it means we’re on the last of the bulleted items, and for that one we can apply the ‘last’ style.

      And I figured this is most easily done as the first GREP, before I change the others.

      Find what:
      (~8)()(.+)()(?!~8)

      Change to:
      $4

      But… doesn’t work. Any tips?

    • #87546

      Hi Aaron,

      this can be done in two steps!

      1. Remove manual bullets
      Find what: •\x20(.)
      Change to: $1 + applied bullet style

      … will find a bullet, followed by a space, followed by any character (the any character is needed, because you can either apply formatting or change something >> with this trick you can do both in one go!)

      2. Find the last bullet para
      Find what: \r(?!.) + applied bullet style
      Change to: nothing + + applied bullet last style

      … will find a return with applied style bulletStyle, if it is not followed by a character with the same formatting. So it will find the last return in a range.

      best
      Kai

    • #87550
      AaronA
      Participant

      Hi Kai,

      Thanks for your response!

      I think your first ‘find’ must have gotten garbled in the forum formatting… ?
      I got it to work with this instead:

      ~8(.)(?# Find bullet character & space & any character)

      And the #2 routine works great. I just figured out why, so this is for the benefit of any other GREP novices: it looks to the first character of the next paragraph; if it does NOT match the specified bullet paragraph style, then the Change (to the ‘last’ bullet par style) is executed.

      Very helpful; thanks again!

    • #87551

      The first ones should be

      ~8\x20(.)

      To your explanation on #2: It looks not to the first character of the next paragraph, since lookararounds find only positions and not characters.

    • #87563
      AaronA
      Participant

      Thanks for clarifying.
      That’s the first I’d seen ‘x20’; is it the equivalent of ‘+’ ?

    • #87582

      No. ‘\x20’ is the shortcut for \x{0x20}. This is another way to notate the unicode-value of a normal space. You can see this, if you select a space and read the value in the information panel.

      While includes all kind of whitespace, the tab, a shift return and a return, \x20 will find only simple spaces :)

    • #87668
      AaronA
      Participant

      A very late thanks, Kai, for clarifying! Never thought of entering unicode values, nor that they were shown in the Info panel. Cheers.

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