7 Replies Latest reply on Sep 7, 2012 2:35 AM by cadispraha

    Grep

    cadispraha Level 1

      Hello, I am a beginner in grep scripting. Could you be so kind and help me? I have a large document with some marks for each type of text. For ex.: <CB_P> text</CB_P> means "text" is bold. I have two problems:
      1. Bolt text can be more times in one paragraph. So normal grep find first <CB_P> and the last one </CB_P> in the same paragraph. And all text between set to bold. I need to find the first one <CB_P> and the first one </CB_P> in one query.

      2. I used <=<CB_P>(.*?)=</CB_P> and then $1 set to bold, but I have to remove all <CP_B> and </CB_P> manualy

       

       

      And I have second question. Is any way to find any paragraph and then next one paragraph set to any other paragraph style?
      Like for Title. One Title is Title paragrahp1 nad next row is a Subtitle (Title paragraph2). Can I find "Title paragraph1" and the next one paragraph set to Title paragraph2 via grep?

       

       

      Is any way to help me? Thank you a lot for your help... Ilja

       



        • 1. Re: Grep
          Eugene Tyson Adobe Community Professional & MVP

          <CB_P> (.+)</CB_P>

           

          Change to

           

          $1

           

          Style

          Bold

          • 2. Re: Grep
            [Jongware] Most Valuable Participant

            cadispraha wrote:

            And I have second question. Is any way to find any paragraph and then next one paragraph set to any other paragraph style?

            Like for Title. One Title is Title paragrahp1 nad next row is a Subtitle (Title paragraph2). Can I find "Title paragraph1" and the next one paragraph set to Title paragraph2 via grep?

             

            No, you would need a script for that.

            • 3. Re: Grep
              TᴀW Adobe Community Professional & MVP

              Not with GREP. I've got a script which does just that though:

              www.freelancebookdesign.com

               

              Look under the "script" tab for a script called "Change Consecutive

              Paragraphs".

               

              There's a demo version to try out.

               

              Ariel

              • 4. Re: Grep
                cadispraha Level 1

                Yes, I did that, but then I need to remove <CB_P>etc. by the next grep.... Here is small ex. what kind of text I need to solve:


                <entry><BB_B_CS>tvářnost</BB_B_CS><CB>, </CB><CB_B>-i</CB_B><CP_KP> ž-</CP_KP><CP_KPB>39</CP_KPB><CB> </CB><BB_B>1 </BB_B><CP_K>(vzhled)</CP_K><CB> </CB><CP__EN>appearance</CP__EN><CB>, </CB><CP__EN>air</CP__EN><CB>, </CB><CP__EN>aspect</CP__EN><CB>, </CB><CP__EN>form</CP__EN><CB>; </CB><CP_K>(krajiny)</CP_K><CB> </CB><CP__EN>face</CP__EN><CB> </CB><BB_B>2 </BB_B><CP_K>(povaha)</CP_K><CB> </CB><CP__EN>nature</CP__EN><CB>, </CB><CP__EN>complexion</CP__EN><CB>; </CB><CB_B_CS>politická t. východní Evropy</CB_B_CS><CB> </CB><CP__EN>the political complexion of Eastern Europe</CP__EN><CB>; </CB><CB_B_CS>dát čemu novou t.</CB_B_CS><CB> </CB><CP__EN>put a different complexion on sth</CP__EN></entry>

                 

                You can see lot of removal to change text to normal. Here is a result

                 

                 

                My problem is, that I need to find only <CP_K>(vzhled)</CP_K> and then "(vzhled)" set to italic, but normal grep find this:
                <CP_K>(vzhled)</CP_K><CB> </CB><CP__EN>appearance</CP__EN><CB>, </CB><CP__EN>air</CP__EN><CB>, </CB><CP__EN>aspect</CP__EN><CB>, </CB><CP__EN>form</CP__EN><CB>; </CB><CP_K>(krajiny)</CP_K><CB> </CB><CP__EN>face</CP__EN><CB> </CB><BB_B>2 </BB_B><CP_K>(povaha)</CP_K>

                 

                My step 2 "<=<CB_P>(.*?)=</CB_P>" can find it, but the result is <CP_K>(vzhled)</CP_K> and then I have to manualy remove <CP_K> and </CP_K>...


                PS. The book has 2000 A4 pages

                • 5. Re: Grep
                  cadispraha Level 1

                  Thx Arïel, looks good. I will buy it .
                  Is any way to add some functionality as in grep/ find in Indesign? I mean choose document, all open documents etc. and buttons "Find first / Change / Change and Find next etc." will be very helpfuly.

                  • 6. Re: Grep
                    [Jongware] Most Valuable Participant

                    <CB_P> (.+?)</CB_P>

                     

                    Change to

                     

                    $1

                     

                    Style

                    Bold

                     

                    (Eugene forgot the question mark, which makes the GREP match the shortest possible match instead of the longest one.)

                    • 7. Re: Grep
                      cadispraha Level 1

                      Thanks a lot for Jongware and Eugene. Their answer it the right one...