1 Reply Latest reply: Dec 10, 2008 12:09 PM by [Jongware] RSS

    Using GREP to eliminate some hyphenations?

    RodneyA Community Member
      Okay, this is out of my depth, but I would love to have a way to automatically turn off hyphenation within the units of email addresses and URLs. Since some URLs contain hyphens, I don't want discretionary ones added, because that creates ambiguity. But URLs are so cumbersome that if you don't allow them to break at periods and "at" signs, they foul up justified paragraphs. So, for instance, rodney@mont-alto.com would be allowed to break before or after @, and before or after the period. Is there a way I can use GREP to (a) find URL and/or email addresses, and (b) apply a character style containing "no break" only to the "words" contained in it, but not to the punctuation characters? And can I set it up as a nested style once I switch to CS4? Any assistance appreciated...

      Rodney
        • 1. Re: Using GREP to eliminate some hyphenations?
          [Jongware] Community Member
          No, it would take separate search-and-find operations to apply "No Break" to some parts and not to others.

          But you can easily search for email and hyperlinks with GREP. I have an enourmously complicated search (on another machine, sorry), but the basic idea is for emails,

          >[-_A-Za-z0-9]+(.[-_A-Za-z]+)*@[-_A-Za-z0-9]+(.[-_A-Za-z0-9]+)+

          (effectively, any combo of "xxx@yyy" with optionally periods before and repeated periods afterwards), and

          >(http://)?www[0-9]*.[-_A-Za-z0-9]+(.[-_A-Za-z0-9/]+)+

          for hyperlinks.

          It'll take some tweaking to get every possible hyperlink (I don't think that's actually possible) -- take, for instance, a "www3." address. My own hyperlink search even can find php parameters, the stuff after a '?', but that makes it way less reliable and I have to manually check each one.