Back

If your email is not recognized and you believe it should be, please contact us.

  • You must be logged in to reply to this topic.Login

GREP – Select Website but NOT commas

Return to Member Forum

  • Author
    Posts
    • #63734
      kingsigma
      Member

      Hi, I'm using this GREP to select websites:

      (?i)(http|ftp|www)(S+)|(S+)(.gov|.us|.net|.com|.edu|.org|.biz)S+

      But in cases like this:

      “For more information about noncredit courses and certificates, e-mail abc.lhcm@efg.edu, visit abc.efg.edu/lhcm, or call (212) 123-4567.”

      The commas after abc.lhcm@efg.edu and abc.efg.edu/lhcm are also selected. Can anyone please advise how to alter this string so it does NOT include the commas in the selection?

      Thanks!

      Brad

    • #63736
      kingsigma
      Member

      Hi, I just realized the backslahes came out. Also, I seem to be able to get it to work if I use TWO expressions instead of one. One changes the e-mail addresses, and the other changes the websites. I can't seem to get them both in one string, though.

      (?<=,)(?i)(http|ftp|www)(S+)|(S+)(.gov|.us|.net|.com|.edu|.org|.biz)S+(?=,)

      AND

      (?<=,)(?i)(http|ftp|www)(S+)|(S+)(.gov|.us|.net|.com|.edu|.org|.biz)(?=,)

      Thanks.

    • #63737
      David Blatner
      Keymaster

      I think backslash-S means “anything that isn't a space” — it's been a while since I used that.

      Check out this site for one of the best (and longest) grep strings for capturing URLs:

      https://daringfireball.net/2010&#8230;..ching_urls

    • #63739
      kingsigma
      Member

      Thanks David! That worked great for the web addresses, but it didn't select any of the e-mail addresses. I'm going to play with it to see if I can get it to work with both.

      Thanks again,

      Brad

    • #63742

      Actually, I don't think any of your original queries selects e-mail addresses either. All of them presume a http, ftp, or www prefix, which is quite uncommon for an e-mail address to start with.

      I don't think it's worth the trouble to attempt to match both web pages and e-mail addresses in one go. They are significantly different, as you've already noticed.

    • #63755
      kingsigma
      Member

      Hmmmm. Ok, thanks guys. Do either of you know of any good expressions that capture an e-mail accurately?

      Thanks,

      Brad

Viewing 5 reply threads
  • The forum ‘General InDesign Topics (CLOSED)’ is closed to new topics and replies.
Forum Ads