17 Replies Latest reply on Feb 28, 2014 12:17 PM by SueCampbell54

    GREP question

    SueCampbell54 Level 1

      I would like to change all the first graphs after a heading to a First graph style. They are currently all styled with a body style. Can I use a GREP search to find the Head style and change the following graph style, leaving the head as is?

       

      I don't want to apply a character style so please don't suggest a GREP style rather than a GREP find/change. This will be in an ebook and I don't want extra span tags.

       

      I just can't wrap my head around the Lookahead Lookbehind expressions. I can't find one that searches for a ¶ style preceding what I want to change (any text in a following graph) to a new ¶style.

       

      Does anyone know the correct string? It would be like this:

       

      Header Styled Line¶

      >Body Styled graph.< 

       

      with only what's between the > < getting a style change.

       

      Thanks for any assistance.

        • 1. Re: GREP question
          Doc Maik Level 4

          For my understanding: what are "first graph style" and "body styled graph"?

          • 2. Re: GREP question
            Peter Kahrel Adobe Community Professional & MVP

            'Graph' probably stands for 'paragraph', right?

             

            The answer to you question is yes, but you need several steps. Here's why: you can search for any Header Styled Line¶, but then you're stuck: you can't get to the following paragraph. To find the paragraph following the head, you'd have to search for Header Styled Line\r. ( \r is the paragraph break). That dot at the end is part of the grep and stands for 'any character', here the first character of the next paragraph. And because that will be a different paragraph style, you won't find anything.

             

            Here's the two-step method:

             

            1. Search \r in your header styled paragraph style, and replace with \r###

            2. Now all the paragraphs following the header-styled line start with ###

            3. Search ^### replace with nithing, and apply Body Style paragraph style

             

            Peter

            1 person found this helpful
            • 3. Re: GREP question
              Obi-wan Kenobi Adobe Community Professional

              Hi,

               

              3 regex into a Multi-Find/Change:

               

              Regex 1:

               

              Search: \r

              Replace: $0@

              Search format: Head style

               

              // Use a character not otherwise used! //

               

              Regex 2:

               

              Search ^@

              Replace format: New style

               

              Regex 3:

              Search ^@

              replace: nothing

               

              Obviously, with MFC: only one click! 

              • 4. Re: GREP question
                Obi-wan Kenobi Adobe Community Professional

                Hi Peter,

                 

                Sorry, I don't see your answer ! 

                • 5. Re: GREP question
                  Doc Maik Level 4

                  @Peter: I don't see why anyone would say "body style paragraph style". There is no "body" in Indesign. You got text boxes (or frames) and objects. You can apply styles to paragraphs or characters or objects. Please don't confuse people trying to help.

                   

                  @Obi-wan: Multi-Find/Change?

                  • 6. Re: GREP question
                    Peter Kahrel Adobe Community Professional & MVP

                    'Body' as in 'body text', as opposed to secondary text. That's normal usage.

                    • 7. Re: GREP question
                      Obi-wan Kenobi Adobe Community Professional

                      See:  http://www.automatication.com

                       

                      MFC is a very helpful script written by Martinho Da Gloria with which we can make multiple search-replace in ID.

                      Otherwise, x Regex (in a "set") but only one click!

                      • 8. Re: GREP question
                        Doc Maik Level 4

                        Peter Kahrel wrote:

                         

                        'Body' as in 'body text', as opposed to secondary text. That's normal usage.

                        Hmm...Never heard of both. But my mother language is German, so this can happen. I searched Google and learned that body text is also main or primary text. But what is secondary text? However, "body text" may be common, but "body style" is not. Paragraph styles are paragraph styles, no matter if they are for body text, secondary text or even footnotes.

                         

                        @Obi-wan: I see. A script. Will have a look. Thanks.

                        • 9. Re: GREP question
                          Peter Kahrel Adobe Community Professional & MVP

                          Secondary text is e.g. tables, notes, references, quotations.

                          'Body style' is just shorthand for 'a paragraph style for body text'.

                          • 10. Re: GREP question
                            SueCampbell54 Level 1

                            Peter,

                            Thank you. This I can understand. The problem with most GREP manuals is that they seem to be written in another language. It should make sense but doesn't because I don't even know what "Regex" means!

                             

                            I did th steps precisely as you wrote them. However, strangely, it is leaving the ### in the re-styled paragraph after the last step. It shouldn't! I have used "nothing" in the "Change to" field. I tried this last step in the GREP tab and in the Text tab think that could be it. But it leaves the ### either way! I do not understand.  I've done this sort of find/change before and it usually works? Clueless what to do now.

                             

                            I am going to find your book though, Peter. It was recommened to me by Erica Gamet.

                             

                            Obi-wan, is Multi-find/change a plug in? Oh, a script. I'll go look for it. Thanks. I'm going to try your solution too. I will report back.

                             

                            Sorry for the imprecise way I described my paragraph styles—Peter's interpretation was correct.

                             

                            Bear with me! I'm trying!

                            Sue Campbell

                            • 11. Re: GREP question
                              Obi-wan Kenobi Adobe Community Professional

                              Hi Sue,

                               

                              Peter forgot the third step (see my proposal). We thought and wrote exactly the same process - which is a "classic" one. Peter uses ###,  I prefer to use @ (if not otherwise used). With MFC, you have only 1 click to do to run automatically the 3 regex one after the other.

                              • 12. Re: GREP question
                                Peter Spier Most Valuable Participant (Moderator)

                                Obi-wan Kenobi wrote:

                                 

                                Hi Sue,

                                 

                                Peter forgot the third step (see my proposal).

                                Actually, Peter incorporated your steps 2 & 3 together in his step 2, but for some reason it's not working for Sue as it should. My bet would be that she's eithger limited the scope of the search improperly, or she left some Find Format in place that shouldn't be there.

                                • 13. Re: GREP question
                                  SueCampbell54 Level 1

                                  Peter S., No, I really didn't—I replicated Peter K's steps exactly. I did find that it was trying to remove the ### and change the body text (indented) style to 1st body text (not indented) style in one step—that was the problem.

                                   

                                  Obi-Wan I finally did figure out what your instructions meant and switching the order of step 2 and 3 (as you did) was the key in getting this to work. Thanks.

                                   

                                  I guess the reason I don'tuse GREP much is that I could have gone through the entire book and implemented the change in the time it's taken to try to troubleshoot this. Sigh.

                                   

                                  I appreciate you guys helping a newbie at GREP. I will check out the Multi F/C script. But understanding the steps is what I needed right now. As I have to hand the file back I can't expect them to use a script (but I can!)

                                   

                                  Sue Campbell

                                  • 14. Re: GREP question
                                    Obi-wan Kenobi Adobe Community Professional

                                    Hello Peter,

                                     

                                    This does not work for me too! It is the reason I use 3 regex.

                                    • 15. Re: GREP question
                                      Peter Spier Most Valuable Participant (Moderator)

                                      OK, I tried it here and get the same failure in both CS5 and CS6 when combining the steps. Now that I think about it, it actually does seem correct, though, that it should behave this way. Leaving the change field blank and adding formatting is really telling ID you want to change the formatting only.

                                      • 16. Re: GREP question
                                        Obi-wan Kenobi Adobe Community Professional

                                        Fine! We can go to sleep! 

                                         

                                        Multi-Find/Change have changed my approach in ID. It is so much easier and faster associate simple (and intuitive) regex rather than find the "Holy Grail" in one!

                                        • 17. Re: GREP question
                                          SueCampbell54 Level 1

                                          Ha. Thanks for staying up! It's my work day now. Good night!