7 Replies Latest reply on Mar 16, 2013 7:06 AM by camilo umaña

    May Grep sequence of codes as $1/2/3/4 etc be tagged as character styles?

    camilo umaña Level 1

      In a  search some of the strings are:

       

      —daughter Diotima Moosbrugger was—

       

      where the Grep is catching words in uppercase between words in lowercase

       

      \<\l{3,}( \u\l{3,})( \u\l{3,})( \l{3,})\>

       

      $1  $2   $3   $4

       

      it is possible to apply a character style to those words in between as $2, $3?

       



        • 1. Re: May Grep sequence of codes as $1/2/3/4 etc be tagged as character styles?
          Peter Spier Most Valuable Participant (Moderator)

          If you apply a character sytle using Find/Change it is applied to ALL of the found text, so I suspect you need to do this in two steps.

          • 2. Re: May Grep sequence of codes as $1/2/3/4 etc be tagged as character styles?
            Peter Kahrel Adobe Community Professional & MVP

            Hi Camilo,

             

            Your problem is this: in order to match two words with initial caps and nothing else, you would need a lookbehind and a lookahead, and lookbehinds cannot be of variable length.

             

            Maybe try a different approach: find all sequences of two or more words in initial capitals:

             

            ((\u\l{3,}\s?){2,})

             

            Peter

            • 3. Re: May Grep sequence of codes as $1/2/3/4 etc be tagged as character styles?
              camilo umaña Level 1

              Hi Peter,

               

              Yes, I was getting mad with that Grep as your formula now allows to go straight to the sequence of uppercase words.

               

              Your formula is the perfect factoring of that very long quoted above.

               

              Thanks for it.

               

              PD. It is possible to apply a character style in the hypothetic situation where we have many $n to one of them?

              I mean: must I explore look/ahead/behind for a solution?


              • 4. Re: May Grep sequence of codes as $1/2/3/4 etc be tagged as character styles?
                Peter Kahrel Adobe Community Professional & MVP

                I'm not sure that I understand what you mean by "where we have many $n to one of them". You can apply a character style to what you find simply by leaving the Change To field empty and specifying a character style in the Change Format panel.

                 

                That expression I gave earlier has a flaw, I realised: it also captures any spaces after the last initcap word. To avoid that, use this expression:

                 

                (\u\l{3,}\s?)+(\u\l{3,})

                 

                In other words,

                 

                (\u\l{3,}\s)+      // match one or more words with initial cap

                (\u\l{3,})           // followed by one word with init cap

                 

                Peter

                • 5. Re: May Grep sequence of codes as $1/2/3/4 etc be tagged as character styles?
                  camilo umaña Level 1

                  Screen Shot 2013-03-16 at 7.47.24 AM.jpg

                   

                   

                  Tried both formulas and made exactly the same replacements: 17.

                  For the moment it seems no difference.

                   

                  Now, with this formula seems impossible to detect some particles like «de» that are sustancial in the f/search:

                  for example two uppercases between Maria de Montesco, as this connector is part of the search.

                   

                  In the old formula it is easily applied:

                  \<\u\l{2,} de( \u\l{2,})+\>

                   

                  For

                  I'm not sure that I understand what you mean by "where we have many $n to one of them".

                  I mean, I only need to apply a character style/a colour to $2 (for example) and leave the $1, $3 without information.

                  May I select only one of the them? 

                   

                  Thank you, Peter.

                   

                  Message was edited by: camilo umaña

                  • 6. Re: May Grep sequence of codes as $1/2/3/4 etc be tagged as character styles?
                    Peter Kahrel Adobe Community Professional & MVP

                    > Tried both formulas and made exactly the same replacements: 17.

                     

                    That's indeed the case. The difference however is that the first one I posted also applies the character style to the space (if any) following the last init-capped name. You can't see that in your document because you apply just the colour. But if you apply e.g. underline or strikethrough, you will see the difference.

                     

                    > Now, with this formula seems impossible to detect some particles like «de»

                     

                    For that, you could use this:

                     

                    (\u\l{2,}\s?)+

                    (de\x20)*

                    (\u\l{2,})

                     

                    and if you wanted other particles (del, della, d', etc.), just list them in the second line:

                     

                    (\u\l{2,}\s?)+

                    ((de|del|della|d')\x20)*

                    (\u\l{2,})

                     

                    > I mean, I only need to apply a character style/a colour to $2 (for example) and leave the $1, $3 without information.

                     

                    That's possible, but you need several steps for that. The trouble is that you can't use a lookbehind because the first name(s) with any particles have variable lengths. What you can do is this:

                     

                    Step 1: apply some code to the first name(s) and any particles (but not the last name), e.g. underlining:

                     

                    Find what:

                    (\u\l{2,}\s?)+

                    (de\x20)*

                    (?=\u\l{2,})

                     

                    Change to: leave empty

                     

                    Change format: underline

                     

                     

                    Step 2: apply your character style to the full names:

                     

                    Find what:

                    (\u\l{2,}\s?)+

                    (de\x20)*

                    \u\l{2,}

                     

                    Change format: remove underline, set your character style

                     

                    Step 3: remove the character style to the text that has both underling and you character style.

                     

                    Peter

                    1 person found this helpful
                    • 7. Re: May Grep sequence of codes as $1/2/3/4 etc be tagged as character styles?
                      camilo umaña Level 1

                      All this greps are really superb pieces!

                      It is the first time I see so detailed and complex examples related to the replace field, scarcely seen in the manuals. 

                      And saving tons of manual work.

                       

                      Really, thanks a lot.