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 Peculiarity – Different result for Selection, Selected Story & Document

Return to Member Forum

  • Author
    Posts
    • #14347242
      Lewis Cooper
      Participant

      Hi all,

      I’ve encountered a strange situation whereby a repurposed FindChangeByList.jsx gives me incorrect results… sometimes! The fix is even stranger to me, but it may also be the clue needed for fixing my GREP.

      I work with a catalogue with prices scattered throughout, and I use a FindChangeByList.jsx script to find a style by code and replace it with it’s respective price. Here’s a rough idea of the starting point with 1234 used to indicate out of date price values for VR17, UE92 and UM81 with vary amounts of text between the codes and their prices:

      Of course, the business end of this script is in the support.txt file. The first line of my .txt file picks out any price and turns it into XX:

      grep {findWhat:"d+,~=s€"} {changeTo:"XX,~=~s€"} {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false}

      Then I use the following (output from an Excel sheet) to drop in the correct prices


      grep {findWhat:"(?s)(VR17.+?)XX,~=s€"} {changeTo:"$1349,~=~s€"} {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false}

      grep {findWhat:"(?s)(UE92.+?)XX,~=s€"} {changeTo:"$1169,~=~s€"} {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false}

      grep {findWhat:"(?s)(UM81.+?)XX,~=s€"} {changeTo:"$1129,~=~s€"} {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false}

      If I run the script with nothing selected it works as expected. If choose to run it on the ‘Selected Story’ or ‘Document’ it also works.

      But… when I run the script having highlighted all of the text in the frame first, i.e. ‘Selection’, the last price isn’t replaced. In fact, it unhighlights the last character.

      If I manually add a single space after the euro symbol then all is good again.

      Is there a flaw in my GREP strings?

    • #14347249
      David Blatner
      Keymaster

      I’m not sure… I don’t think it is the GREP expression… it sounds like it may just be a bug with InDesign. I never use the script when text is selected… I only run it when no text is selected, so I have not seen this.

    • #14347737
      Aaron Troia
      Participant

      The FindChangeByList is quite the quirky GREP script. It seems straight forward but you really have to play by its rules and test to learn what it will and will not accept. I wish it used the same GREP engine that Find/Change uses (why it doesnt is beyond me). Like David said, I would also guess that this is a bug.

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