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 inconsistency finding variable? Or am I holding it wrong?

Return to Member Forum

  • Author
    Posts
    • #63578
      Jake Overton
      Member

      I was playing with GREP find (I suppose the problem exists in other places like GREP styles), and am having trouble getting it to find a text variable (filename) with a lookahead.

      I have a string in a text frame that is XXXXfilename where filename is a text variable. I can search successfully for (.)~l and it finds the filename and the character before it. However, if I use (.)(?=~l), it doesn't find any match. Why is this failing? There is no logic as to why it would find the string with the text variable as part of the search string, but not when it is a positive lookahead. I can find no documentation (such that it is) on how it handles text variables when doing a positive lookahead.

      Thanks,

      Jake

    • #63579

      That's really interesting. I have some text such as “A:1″, where the number is a custom variable, and I can find it using

      :~u

      To find just the colon, I expected this to work:

      : (?=~u)

      It doesn't, so let's try the inverse: find a colon where there is no variable following!

      : (?!~u)

      This also matches nothing … and I'm totally sure one of these two ought to have found something!

      InDesign's GREP is great (in general), but one of the most annoying featurettes is that it does not tell you why a particular search failed. A “bad” GREP expression gives the same result as a no-match-found: “Cannot find match”. But if a plain search finds nothing and the inverse (finding it “not”) also finds nothing, then you can be pretty sure ID just does not understand the expression.

      Since lookahead does work correctly with other 'tilde' codes such as ~., I'm inclined to call out Bug, and you may very well report it to Adobe with a Bug Report.

    • #63580
      Jake Overton
      Member

      Thanks, jongware. I have submitted this at Adobe, though I hold no expectations of a quick fix. I am glad to see that I am not crazy and that you also saw what I did.

      Jake

    • #63589
      Lala Lala
      Participant

      Weird thing I found while playing around with this.

      I typed sample text, XXXX then from the menu type –> insert –> text variable –> filename. Resulting in XXXXUntitled-2.

      I tried your non-working lookahead and it didn't work for me either.

      Then I threw a single letter, v, in front of the XXXX.. Then I tried looking for (.)(?=.+~l)

      …meaning, I added [any character, one or more times] into the lookahead. That actually worked, it highlighted the v in the text string vXXXXUntitled-2

      Here's where it gets weird. If I insert yet another character, for example vvXXXXUntitled-2, it doesn't find it UNLESS the cursor happens to be exactly five characters to the left of “Untitled-2”. This is regardless of whether I search document, story, selection, etc. So if the cursor is at the very beginning of vvXXXXUntitled-2, no match. Move it over to the right once… match. Move it over to the right again… no match.

      It seems this is the behavior regardless of how many characters I put in front of the filename. There's some significance to it about being exactly 5 characters in front of the filename variable.

      Unfortunately this does seem to indicate a bug, and without a real practical workaround.

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