10 Replies Latest reply on Nov 10, 2011 10:38 AM by jay fresno

    GREP style as part of paragraph style

    jay fresno Level 1

      I'm wanting to create a GREP style that uses a character style. Whenever certain words (No class) appear followed by dates. Sometimes it is a single date and sometimes more than one date. For example:

       

      No class 7/11.

      No class 7/11-8/11.

       

      What I have so far is:

      No class \d+.

       

      This works okay through the words "No class" and the first digit, but not for the whole sentence. I've tried different combinations but nothing that works correctly.

       

      Can anyone help?

        • 1. Re: GREP style as part of paragraph style
          Peter Kahrel Adobe Community Professional & MVP

          If you want to target the whole paragraph, use this:

           

          ^.+No class \d.+

           

          The caret stands for "beginning of paragraph". Not sure iof this is what you want, though.

           

          Peter

          • 2. Re: GREP style as part of paragraph style
            jay fresno Level 1

            Peter,

            Thank you so much for your suggestion. I'm targeting one sentence within a paragraph, and the paragraph has one or more sentences of text before, and text after, the sentence that I need to work with. Is this possile?

            • 3. Re: GREP style as part of paragraph style
              Peter Kahrel Adobe Community Professional & MVP

              Probably, but the difficulty is how you define "sentence". Maybe "a string of characters from an upper-case letter up to a full stop, where the upper-case letter is either the first letter in a paragraph or preceded by a full stop and a space"?

               

              (?<=\.\s)?                 //full stop followed by a space. ? catches first sentence in paragraph

              \u.+No class\s\d       //upper-case letter (\u) followed by one or more characters (.+), followed by "No class" followed by a space (\s)

              .+(?=\.)                     // one or more characters (.+) followed by a full stop (\.).

               

              The final full stop must be in a lookahead, otherwise you find every other sentence instead of every sentence.This fails if there are periods between "No class [dates]" and the end of the sentence.But your two examples are followed by a full stop: if that's always sentence-final, then you could use this:

               

              (?<=\.\s)?\u.+No class\s[-\d/]+

               

              Probably needs some more tweaking though.

               

              Peter

              • 4. Re: GREP style as part of paragraph style
                jay fresno Level 1

                Peter,

                 

                The paragraph needs to look like this:

                Untitled-2.gif

                This  is one example. I have many such paragraphs to work with throughout the  catalog. The number of sentences before the date paragraph varies. The  date itself varies because sometimes it's something like 7/11 and  sometimes it's something like 7/11-7/18. The bold instructor name is  done with a nested style that triggers on an en space. I could do the  italic date using a nested style, but didn't want the hassle of putting in a  special character to trigger the change to italic. (Don't like the hassle of triggering the bold instructor name with a special character either, but that's the only way I could figure out to do it.)

                 

                If I use this:

                (?<=\.\s)?\u.+No class\s[-\d/]+

                The text following the date sentence also takes on the italic character format.

                 

                Untitled-1.gif

                 

                If I use

                (?<=\.\s)?\u.+No class\s[-\d/]+

                The text before the date paragraph becomes italic.

                 

                 

                • 5. Re: GREP style as part of paragraph style
                  Peter Kahrel Adobe Community Professional & MVP

                  I think I'm slowly beginning to understand. So you have paragraphs that (may) end in "No class . . . Instructor: . . ." Here's another shot:

                   

                  No class\s[-\d/]+  // Match "No class" followed by a space, then by one or more hyphen, digit, slash.

                   

                  To bold from Instructor to the end of the paragraph, you could use this:

                   

                  Instructor:\s.+$

                   

                  (Though the $ isn't striclty necessary.)

                  • 6. Re: GREP style as part of paragraph style
                    jay fresno Level 1

                    Peter,

                     

                    I so much appreciate your help with this. Your explanation makes it understandable. But there is still a mystery.

                     

                    The GREP for Instructor: Instructor Name works fine. The GREP for the date sentence is not working. Instead of the date sentence becoming italic, it  matches the first part of the paragraph. This is what the GREP looks like:

                    Untitled-1.gif

                    This is what the paragraph looks like with the GREP applied:

                    Untitled-4.gif

                    It should look like this:

                    Untitled-5.gif

                    -------------------------

                     

                    In a separate issue in another paragraph, which is a heading paragraph, I have a similar situation. The headings are bold, some headings list ages, and some list ages AND whether parental participation is required. I thought I could extrapolate from the information you've given me to fix this paragraph as well. I've tried different combinations, but so far haven't gotten it to work. The paragraph looks like this:

                    Untitled-2.gif

                    But it needs to look like this (bold paragraph with ages in regular,and parent requirement in italic):

                    Untitled-3.gif

                    The heading doesn't always have an age requirement, and doesn't always require parental participation.

                     

                    The catalog is quite long, so if there is a way to fix these two types of paragraphs, it would save a ton of time.

                    • 7. Re: GREP style as part of paragraph style
                      Reese 0o0o

                      the date part of the grep code should just be

                       

                      No class\s[\d/]*

                      • 8. Re: GREP style as part of paragraph style
                        Reese 0o0o Level 1

                        [\d.]+[-My,]+

                        that should catch your possible months to years string including the comma
                        and you can just use the exact string 'requires parent participation' for the last part.
                        1 person found this helpful
                        • 9. Re: GREP style as part of paragraph style
                          Peter Kahrel Adobe Community Professional & MVP

                          Jay

                           

                          The first grep expression in your screenshot doesn't work because you added  //, which I should have mentioned should be left out (including any preceding spaces) -- sorry about that. It should read just this:

                           

                          No class\s[-\d/]+

                           

                          The hyphen is needed to match dates like 7/11-8/11.

                           

                          As to the headings with dates and optional parental guidance, this one works on your example:

                           

                          \d[-\d\.My]+[My](, requires.+)?

                           

                          which is a bit safer than Reese's because it requires that the date ends in M or y. The ? following (, requires) makes the parenthetical optional. Remember that grep is case-sensitive: if your months can be lower-case m as well, use [-\d\.Mmy] for your character class. You may need to tighten up the grep to match dates depending on the possible formats.

                           

                          Peter

                          • 10. Re: GREP style as part of paragraph style
                            jay fresno Level 1

                            Thanks for your  help on this. I got so wound up in just meeting deadlines that I didn't have a chance to get back to you until now.