GREP find not working in javascript

Learn / Forums / InDesign Add-ons (Scripts, Scripting, and Plug-ins) / GREP find not working in javascript

Viewing 3 reply threads
  • Author
    Posts
    • #67399

      I am writing a script that uses several grep find/change queries. They all work apart from this one “\\Z\\r” that aims to delete the last return at the end of a story.

      This and variations of it work fine in the find/change dialog but not in the script. Any help would be much appreciated.

    • #67404

      In a script, try using positive lookahead “\\r(?=\\Z)” for findWhat property. Note, this will also delete the last return at the end of any table cell as well. Works in InDesign CS6.

    • #67424

      Actually you don’t need a lookahead for the ‘position markers’ $ and \Z. Stuart mentions he tried some variations, but maybe he overlooked the simplest possible case:

      \\r\\Z

      — that is, the return occurs *before* the end of story.

      • #67426

        I thought that should work, but I tried \\r\\Z using InDesign CS6 on Mac and could not get it to work.

      • #67427

        \\r\\Z does appear to work in InDesign CC.

    • #67428

      Thank you guys for your help with this. Jongware, I could have sworn I’d tried that variation but obviously not as it works a treat in CC.

Viewing 3 reply threads
  • You must be logged in to reply to this topic.
>