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 script: Search for "?.+" and apply character style?

Return to Member Forum

  • Author
    Posts
    • #33896
      frankeman90
      Member

      Having spent hours on this I almost give up. I guess it is not a big problem for everyone, but I am kind of new on scripting.

      My problem:

      I have a Indesign table (500 + pages) and need to apply character styles to all the content. To make things easier I have inserted a special character eg. “?”, “?” before every pargraph.

      What I need to do:

      1. A search for every paragraph beginning with “?” and applying paragraph style named “APPLE”

      2. A search for every paragraph beginning with “?” and applying paragraph style named “BANANA”

      3. Deleting the characters “?” and “?”.

      Any suggestions?

      https://tinypic.com/r/ogw3dw/5

      [IMG]https://i42.tinypic.com/ogw3dw.png[/IMG]

    • #33902
      David Blatner
      Keymaster
    • #33906
      frankeman90
      Member

      Yes, I have been looking in to the findchangebylist but cannot understand how to make it change paragraph style based on an grep-search.

      Any chance you could help me out?

      (And thanks for the DTP Tools, use them every day ;-)

    • #33908
      frankeman90
      Member

      Finally got it to work with the script below. But do you know how I can make this only affect the selected text / text frame?

      app.findGrepPreferences=app.changeGrepPreferences=null;

      app.findGrepPreferences.findWhat=”?(.+)$”;

      app.changeGrepPreferences.changeTo=”$1″;

      app.changeGrepPreferences.appliedParagraphStyle=”APPLE”;

      app.activeDocument.changeGrep();

      app.findGrepPreferences.findWhat=”?(.+)$”;

      app.changeGrepPreferences.changeTo=”$1″;

      app.changeGrepPreferences.appliedParagraphStyle=”BANANA”;

      app.activeDocument.changeGrep();

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