2 Replies Latest reply on Jan 10, 2013 6:13 AM by smashkirk

    GREP code request (easy)

    smashkirk Level 1

      This should be easy for the GREP experts out there.

       

      I would like to set a style to all my web links in my text. So, I'm looking for some code which will select any text that starts with "www" or "http" and select up to but not including the next space (because there are no spaces in web addresses).

       

      Let me know if further clarification is needed.

       

      Thanks!

       

      Ak

        • 1. Re: GREP code request (easy)
          [Jongware] Most Valuable Participant

          That would be this:

           

          \b(www|http)\S+

           

          where "\b" is a word break ('.. any text that starts ..'), (www|http) is the plain text "www" or "http" ('.. with "www" or "http" ..), and "\S+" is not-a-space, as much as humanly possible ('.. select up to but not including the next space ..').

           

          So it'll do exactly what you specified, but please note that this is ever so slightly different than what you meant to: "set a style to all my web links", because it will not find web links that start with something else than 'www' or 'http' (forums.adobe.com, for example, starts with 'forums'). In addition, no there aren't spaces in web addresses, but not everything that is not a space is part of a web address (forums.adobe.com, for example -- the comma right after the URL).

          • 2. Re: GREP code request (easy)
            smashkirk Level 1

            This works, thank you.

             

            You're right about it not catching all web addresses though. I'll have to go through and double check it. But it's still makes my life easier.

             

            Thanks

            Ak