3 Replies Latest reply on Jan 25, 2012 12:48 PM by SJRiegel

    Grep perhaps?

    Karl B Cartwright

      Win7 - ID 5

       

      Typical Directoy Listing

       

      Heading

       

      Name

      Address

      Address2

      Phone

       

      Name

      Address

      Address2

      Phone1

      Phone2

       

      Name

      Address

      Phone1

      Phone2

       

      Heading

       

      Name

      Address

      Address2

      Phone1

      Phone2

       

      Etc...

      I thought I might be able to use some automation to identify the Heading, and apply a paragraph style.  And Identify the Name and apply another style.  The listings are not always the same number of lines and each heading does not have he same number of listings.

       

      I really am fumbling through grep, and was able to have it find the Name. But to do that I looked for the 2 \r in front of them, and in doing so, it applied the formatting to those lines as well.

       

      I appreciate any suggestions.

        • 1. Re: Grep perhaps?
          SJRiegel Adobe Community Professional & MVP

          I have a suggestion - it's less than perfect, but it may be of some help. It finds the text between the returns without changing formating on the returns themselves.

           

          For this to work, you would have to do find Name first -- like this:

           

          (?<=\r\r).+(?=\r) This will find the Names, but also the Headings. Change the style to your Names style

           

          Then serach for just the headings like this:

          (?<=\r\r).+(?=\r\r)

           

          The problem is that the Headings one won't find one at the beginning of the listing, without the returns before.

          • 2. Re: Grep perhaps?
            Karl B Cartwright Level 1

            Yup.  Perfect enough!  I figured I might have to do a couple queries, so that's not unexpected.

             

            Thank you.  That did the trick.

             

            I understand parts of that, but if you dont mind, would you explain how that worked?  It will help me be more self sufficent...

             

            Find and Replace with grep has saved me hours of work.  With a little more understanding, it could save me more...

             

            Thanks again!

            • 3. Re: Grep perhaps?
              SJRiegel Adobe Community Professional & MVP

              These queries use lookahead and lookbehind. They find the match including what is before or after, but only apply the change the the unbracketed text. Here it the Name query broken out with jongware's handy script what the grep.

               

              (?<=\r\r).+(?=\r)

               

              (?<=    Lookbehind Group

                  \r    Paragraph Break (Hard Return)

                  \r    Paragraph Break (Hard Return)

              )    End Lookbehind Group

              .    Any single character

              +    Matching any character may occur once or more times; longest possible match will be taken

              (?=    Lookahead Group

                  \r    Paragraph Break (Hard Return)

              )    End Lookahead Group