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

Code not working in GREP Style compared to Find/Change

Return to Member Forum

  • Author
    Posts
    • #75787
      Masood Ahmad
      Participant

      Hi there,

      I am stuck with one GREP Style. The code works fine with the GREP Find/Change, but fails when used in GREP Styles:

      Find What: ^.+(?=(\r\r(?i)about the location(?-i)))
      Change to Format: UK Location

      The above code works fine, but when I used the same in the GREP Style, then it didn’t do anything:
      Apply Style: UK_Location
      To Text: ^.+(?=(\r\r(?i)about the location(?-i)))

      The purpose of the code is to apply a character style to the paragraph just before the two para-returns and the text ‘About the location’ For example:


      Dorset

      About the location

      Bedford

      About the location

      In the above example, the words ‘Dorset’ and ‘Bedford’ needs to be styled with the ‘UK_Location’ character style. Also note that it could be anything not just Dorset or Bedford.

      Please advise where I’m lacking…

      Thanks in advance.

    • #75790
      Anonymous
      Inactive

      Thinking about it – it can’t work logically with hard returns.

      The GREP style runs on each paragraph independently

      Dorset – the GREP style looks for that combination you’ve posted, doesn’t find, doesn’t do anything.

      Then it goes to the next paragraph – About the location – again doesn’t find that regex.

      It’s running on each paragraph independently, unlike a find which looks at the text as a whole to find things.

      You can do it – but you should use Soft Returns (shift Return) instead of hard paragraph returns.

      Substitute \r with

    • #75791
      Anonymous
      Inactive

      Here – I”ve done this without GREP but rather simple Line Styles

      https://www.filedropper.com/screenshot2015-06-03at143852

    • #75792
      Anonymous
      Inactive

      Please do not click that link!!! Sorry – use my trusted ad free dropbox instead.

      https://www.dropbox.com/s/qwbmf2v3w8wx5g7/Screen%20Shot%202015-06-03%20at%2014.38.52.png?dl=0

    • #75795
      Masood Ahmad
      Participant

      Hi Eugene,

      Thanks for trying this for me, but this is not the case. Nested Styles won’t work as the string I’m trying to style is a part of huge text, running into multiple pages. In that long-text, the location occurs several times, therefore, I’m trying to automate the styling. The only condition that matches with the location is that there are two hard returns and a heading ‘about the location’ running after it.

      To Text: ^.+(?=(\r\r(?i)about the location(?-i)))

      I have achieved this through a trick but that is leading me to an additional step.

      Any other ideas…

    • #75797
      Anonymous
      Inactive

      I don’t see how that would ever work in the styles – as it would search each paragraph independent of one another, not reading it all together.

      You could do a find and replace

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