9 Replies Latest reply on Mar 1, 2012 7:58 AM by jocstone_me

    IDCS5: GREP Positive Lookahead problem

    Iain Robinson Level 1

      Hi all

       

      We've been using a GREP for a while to put a bullet character at the end of the second last para;

       

      Find: \r(^.+$\z)

      Change: ~S\x{25CF}\r$1   //\x{25CF} being the bullet character

       

      It works fine but I have just noticed that when there is a hyperlink at the end of the last para it is broken when that para is captured and then put back again (as $1) by the GREP. The hyperlink seems to have 'shifted' a few characters along;

       

      GREP.png

      What I really want to do is put the last para and the \z in the positive lookahead, so the last para is not captured then put back again. But when I try;

       

      Find: \r(?=^.+$\z)

       

      it doesn't find anything, presumably because \z doesn't like being in the positive lookahead, yet if (as a test) I try

       

      Find: \r(^.+$)(?=\z)

       

      that is okay. So, can someone explain why \z doesn't work in my second expression above but does in the third? Or if someone can think of an alternate way of doing what I want, that would be great.

       

      thanks,

      Iain

       

      PS I hope the expressions come out okay!