7 Replies Latest reply on Apr 6, 2009 1:30 AM by Kasyan Servetsky

    Email Addresses - FindChangeList

      I want to apply a style to email address in my copy. I used the following in my FindChangeList.txt file, but it's not working for some reason. Could someone help please? Alternatively, if you know how to style the last two lines of any story, that'd be even better! THANK YOU!

      text {findWhat:"\@/:[:space:]]+\>@[a-zA-Z_\.]+?\.[a-zA-Z]{2,3}"} {appliedCharacterStyle:"NewsBriefs_Start"} {includeFootnotes:true, includeMasterPages:true, includeHiddenLayers:true, wholeWord:false}
        • 1. Re: Email Addresses - FindChangeList
          Kasyan Servetsky Level 5
          Hi Veronica,

          I have no idea why FindChangeByList.jsx script doesn't work. What strikes my eye is that your line contains mistakes:
          Instead of "text" it should be "grep" – this is a GREP search
          You can't use 'wholeWord:false' in GREP search. Do you see 'Whole Word' in GREP panel?
          Anyway, It's much easier to write a script from scratch.

          Kasyan

          app.findGrepPreferences = app.changeGrepPreferences = null;
          
          var myCharacterStyle = app.activeDocument.characterStyles.item("NewsBriefs_Start");
          if (myCharacterStyle == null) {
             alert("Character style \"NewsBriefs_Start\" doesn't exist in the current document.");
             exit();
          }
          app.findChangeGrepOptions.includeFootnotes = true;
          app.findChangeGrepOptions.includeHiddenLayers = true;
          app.findChangeGrepOptions.includeMasterPages = true;
          //Regular expression for finding an email address.
          app.findGrepPreferences.findWhat = "(?i)[A-Z]*?@[A-Z]*?[.]...";
          app.changeGrepPreferences.appliedCharacterStyle = myCharacterStyle;
          app.activeDocument.changeGrep();
          app.findGrepPreferences = app.changeGrepPreferences = null;
          alert("All done!");
          • 2. Re: Email Addresses - FindChangeList
            Level 1
            Thanks Kasyan! I'll try this. Also if anybody can tell me how to find an email address AND the first line above it (sample below), that'd be great. I need to find the last email address in a story and the first line above it, and have a paragraph style applied. I'm definitely a novice with jsx and grep, so all help is greatly appreciated! Thanks again!

            Writer Name
            wname@example.com
            • 3. Re: Email Addresses - FindChangeList
              Level 1
              One other thing -- for some reason this grep isn't finding my email address in InCopy. It's finding it perfectly in InDesign? This is probably a very easy solution that I'm overlooking? Thank you very much!

              (?i)[A-Z]*?@[A-Z]*?[.]...
              • 4. Re: Email Addresses - FindChangeList
                Kasyan Servetsky Level 5
                Veronica,

                This script works for me in InCopy as well. I noticed that after running FindChangeByList.jsx my script stops working until I restart the program. May be you have the same problem. But it’s still unclear to me: Do you want to apply "NewsBriefs_Start" character style to an e-mail address and some paragraph style to the line above, or the character/some paragraph style to both?
                Could you send me an example document? It would be easier to me to help you if I could see the actual file.

                Kasyan
                askoldich@yahoo.com
                • 5. Re: Email Addresses - FindChangeList
                  Level 1
                  Hi Kasyan
                  Thanks again! To answer your question, I want to apply a paragraph style to the last email address in the story AND the first line above it. So you'd have regular bodytext all the way down to the two last lines which is the author's byline.

                  This is my story and then my story ends.{BODYTEXT STYLE}
                  Veronica Olvera {BYLINE STYLE}
                  veronica@example.com {BYLINE STYLE}

                  Thanks!!
                  • 6. Re: Email Addresses - FindChangeList
                    Level 1
                    Apologies for all the postings, but I have a breakthrough. The below Grep works in INDESIGN. However, I need two things:

                    1) I need it to work in INCOPY
                    2) I need it to apply a paragraph style, NOT a character style

                    All help is appreciated.

                    app.findGrepPreferences = app.changeGrepPreferences = null;
                    var myCharacterStyle = app.activeDocument.characterStyles.item("Hyperlink");
                    if (myCharacterStyle == null) {
                    alert("Character style \"Hyperlink\" doesn't exist in the current document.");
                    exit();
                    }
                    app.findChangeGrepOptions.includeFootnotes = true;
                    app.findChangeGrepOptions.includeHiddenLayers = true;
                    app.findChangeGrepOptions.includeMasterPages = true;
                    //Regular expression for finding an email address.
                    app.findGrepPreferences.findWhat = ".*\r(?i)[A-Z]*?@[A-Z]*?[.]...";
                    app.changeGrepPreferences.appliedCharacterStyle = myCharacterStyle;
                    app.activeDocument.changeGrep();
                    app.findGrepPreferences = app.changeGrepPreferences = null;

                    alert("All done!");
                    • 7. Re: Email Addresses - FindChangeList
                      Kasyan Servetsky Level 5

                      Hi Veronica,

                       

                      This works in InCopy for me: the paragraph style is applied both to e-mail address and the line above. May be your text has a local formatting applied and the paragraph style should be applied with ‘clear overrides’.

                       

                      Kasyan

                       

                       

                      app.findGrepPreferences = app.changeGrepPreferences = null;
                      var myParagraphStyle = app.activeDocument.paragraphStyles.item("Hyperlink");
                      if (myParagraphStyle == null) {
                      alert("Paragraph style \"Hyperlink\" doesn't exist in the current document.");
                      exit();
                      }
                      app.findChangeGrepOptions.includeFootnotes = true;
                      app.findChangeGrepOptions.includeHiddenLayers = true;
                      app.findChangeGrepOptions.includeMasterPages = true;
                      //Regular expression for finding an email address.
                      app.findGrepPreferences.findWhat = ".*\r(?i)[A-Z]*?@[A-Z]*?[.]...";
                      app.changeGrepPreferences.appliedParagraphStyle = myParagraphStyle;
                      app.activeDocument.changeGrep();
                      app.findGrepPreferences = app.changeGrepPreferences = null;

                      alert("All done!");