12 Replies Latest reply: Jul 8, 2009 2:57 PM by mattaca RSS

    GREP find/change can't change all

    mattaca Community Member

      I work for a cookbook publisher, and since certain elements of the book show up frequently I've been experimenting with using GREP to style text. For example, I've created a find/change that looks for any paragraph that starts with the word "Makes" or "Serves" and sets it to the correct style (Recipe - yield). I also created a search for a standard carriage return with positive lookahead for the word "Makes" or "Serves" to style recipe titles. Both of them work beautifully.

       

      However, I'm having a bit of trouble with the paragraph AFTER the Makes/Serves paragraph. I have it set to search for (?<=~b) with the paragraph style set to Recipe - yield in Find Format options. The cursor pops to the beginning of the next paragraph, which is what I want. Then the Change Format options tell it to change the paragraph style to Recipe - headnote.I can go through the document and it will consistently Find Next and Change as desired, but when I try to Change All it says "Search is completed. 0 replacement(s) made."

       

      Is there some kind of rule that at least one character has to be selected to Change All, rather than just having an inserted cursor? I can't think of why else it would be doing this.If so, can anyone think of a workaround? I'd like this to be part of a script.

        • 1. Re: GREP find/change can't change all
          FivePicaPica Community Member

          I think the problem is that the characters you're lookng for aren't in the Find Format format, so can't be selected.

           

          Probably the quickest way is to use the change/find unless you can work in a GREP that will select the entire line before regardless of format. I always have trouble getting those GREPs to work.

          • 2. Re: GREP find/change can't change all
            [Jongware] Community Member

            Try with a single period after your search expression -- the match-any wildcard -- so it has something to select.

            • 3. Re: GREP find/change can't change all
              FivePicaPica Community Member

              I've been experimenting with these strings for the same reason, but the "Find Format" restricts the search.

               

              I've been experimenting with strings like this:

              ^(makes(\w*\s*[[:punct:]]*){4,10}|serves(\w*\s*[[:punct:]]*){4,10})

               

              Which would put the cursor in the following paragraph,

               

              But it stops working once the lookbehind is thrown in.

              (?<=^(makes(\w*\s*[[:punct:]]*){4,10}|serves(\w*\s*[[:punct:]]*){4,10}).

              • 4. Re: GREP find/change can't change all
                mattaca Community Member

                "I think the problem is that the characters you're lookng for aren't in the Find Format format, so can't be selected."

                 

                You are correct, FivePicaPica.

                 

                Jongware said: "Try with a single period after your search expression -- the match-any wildcard -- so it has something to select."

                 

                I can't do that, because then it will look for a single character that has the Recipe - yield style applied to it. That style is only applied to the paragraph before. I could remove the paragraph style from the find format, but then it would find ALL characters preceded by a standard carriage return. I tried using (?<=^Makes.+~b). [meaning any character preceded by a paragraph that starts with Makes followed by one or more characters followed by a return] but that isn't finding anything.

                 

                Is there any other way to find a paragraph that follows a paragraph that starting with a certain word?

                • 5. Re: GREP find/change can't change all
                  L. Tournier Community Member

                  Hi,

                  A positive lookbehind don't accept wildcards  * + or ? The expression, inside the positive lookbehind, must be  fixed length.

                  • 6. Re: GREP find/change can't change all
                    mattaca Community Member

                    Thanks, L. Tournier. I didn't know that. That still doesn't explain, though, why I can't Change All when using my original expression of (?<=~b)

                     

                    Is it not possible to change all unless something is selected? Are there any other ways this could be done?

                    • 7. Re: GREP find/change can't change all
                      FivePicaPica Community Member

                      You might be stuck with manual styling.

                      In the cookbooks I do, I use a lot of setups with "next style"

                      I mainly work with full page recipes, so I tend to need to look at each page anyway to apply styles.

                       

                      I set mine up as (depending on the format)

                       

                      recipe title, next style yield

                      yield, next style

                      recipe introduction, next style same

                       

                      method 1st paragraph, next style method paragraph

                      method paragraph, next style same

                       

                      I've yet to set up the FindChangeByList script to handle primes, dimension x's, standard fractions, etc., but I won't be working on another cookbook without setting that up first...

                      • 8. Re: GREP find/change can't change all
                        mattaca Community Member

                        I thought "next style" only worked if you're typing directly into the document or if it's built into an object style. If there's another way to use "next style," I would love to know about it.

                        • 9. Re: GREP find/change can't change all
                          [Jongware] Community Member

                          Select a number of paragraphs, then right-click the style name in the Paragraph Styles panel. In the drop down menu, select "Apply this, then Next Style". It will automatically use every single style's Next Style per paragraph until it reaches one with "Same style", and that will be applied to the rest.

                           

                          Unfortunately, you cannot bind this command to the style's shortcut key (that's high on my wish list).

                          • 10. Re: GREP find/change can't change all
                            mattaca Community Member

                            Hmm...I'm not seeing that option. I see "Apply 'Body - Text'" and "Apply 'Body - Text,' clear overrides". Are you on a PC? I'm on ID CS4 6.0.3 on a Mac running 10.4.11. If not a PC, maybe you installed some kind of plugin?

                             

                            Thanks for the suggestion anyway!

                            • 11. Re: GREP find/change can't change all
                              [Jongware] Community Member

                              I am on a PC, but the difference is not that great!

                              I think you don't get the additional options because your Next Style is not defined properly (it may be [Same style], so it would do the same as applying the style to the selection).

                               

                              I have this set up in the majority of my templates:

                               

                              SectionTitle -> next style: Title

                              Title -> next style: Author

                              Author -> next style: Affiliation

                              Affilitation -> next style: Abstract

                              Abstract -> next style: Keywords

                              Keywords -> next style: Heading1

                              Heading1 -> next style: Body1st

                              Body1st -> next style: BodyText

                              BodyText -> next style: [Same style]

                               

                              A long list of dependencies, but I can select the entire first page of a document and apply "Section Style, then Next Style".

                               

                              Are you sure you are selecting more than a single paragraph?

                              • 12. Re: GREP find/change can't change all
                                mattaca Community Member

                                Ah, I see it now. It only shows it as an option when you right click if you select a style that HAS a next style defined. I guess that makes sense. InDesign has gotten a little too smart for me!