1 Reply Latest reply on Aug 28, 2012 2:00 AM by Peter Kahrel

    search and apply two paragraph styles using GREP

    M Karthik Level 1

      Hi All,

       

      i am trying to find and apply two paragraph styles within one stroke using script

       

      <chOut>CHAPTER OUTLINE 
      1.1 A BREIF HISTORY
      1.2 CHARACTERISTICS OF BEVERAGES
      1.3 CLASSIFICATION OF BEVERAGES
      1.3.1 NON-ALCOHOLIC BEVERAGES
      1.3.2 ALCOHOLIC BEVERAGES</chOut>
      

       

      I am using the below script to apply the style. But it does not work please help me..

       

      app.findGrepPreferences = NothingEnum.nothing; 
      app.changeGrepPreferences= NothingEnum.nothing; 
      app.findGrepPreferences.findWhat= "<chOut>(.*?)<\/chOut>"; 
      myResults=app.activeDocument.findGrep();
      for (i = 0; i <= myResults.length - 1; i++) 
      { 
      myResults[i].appliedParagraphStyle = app.activeDocument.paragraphStyles.item("BL_F"); 
                myResults[i].paragraphs[0].appliedParagraphStyle = "BL_F";
      }
      //app.changeText(undefined, false, false, undefined,{},{});
      

       

      Thanks

      Karthik

        • 1. Re: search and apply two paragraph styles using GREP
          Peter Kahrel Adobe Community Professional & MVP

          The dot (.) doesn't match the returns (\r) at the end of each line. Add (?s) in front of the expression. There's no need for the parentheses (they make the expression less efficient), and you can use .+ (one or more) instead of .* (zero or more) -- unless of course you want to match zero characters between your tags. Use this expression:

           

          "(?s)<chOut>.+?<\/chOut>"

           

          Peter

          1 person found this helpful