(?xi)
(?:
    \b
    (                      # Capture 1: entire matched URL
      (?:
        (https?://)             #protocols
        |                       #   or
        www\d{0,3}[.]           # "www.", "www1.", "www2." … "www999."
        |                           #   or
        [a-z0-9.\-]+[.][a-z]{2,4}/  # looks like domain name followed by a slash
      )
      (?:                       # One or more:
        [^\s()]+                  # Run of non-space, non-()
        |                           #   or
        \([^\s()]+\)              # Something in parens
      )+
      (?:                       # End with:
        \([^\s()]+\)              # Something in parens
        |                           #   or
        [^\s`!()\[\]{};:'".,<>?«»“”‘’]        # not a space or one of these punct chars
      )
    )
|
    # raw domain name
    (?:^|\s)
    (
        [a-z0-9.\-]+[.](MUSEUM|TRAVEL|AERO|ARPA|ASIA|EDU|GOV|MIL|MOBI|
            COOP|INFO|NAME|BIZ|CAT|COM|INT|JOBS|NET|ORG|PRO|TEL|
            A[CDEFGILMNOQRSTUWXZ]|B[ABDEFGHIJLMNORSTVWYZ]|
            C[ACDFGHIKLMNORUVXYZ]|D[EJKMOZ]|
            E[CEGHRSTU]|F[IJKMOR]|G[ABDEFGHILMNPQRSTUWY]|
            H[KMNRTU]|I[DELMNOQRST]|J[EMOP]|
            K[EGHIMNPRWYZ]|L[ABCIKRSTUVY]|M[ACDEFGHKLMNOPQRSTUVWXYZ]|
            N[ACEFGILOPRUZ]|OM|P[AEFGHKLMNRSTWY]|QA|R[EOSUW]|
            S[ABCDEGHIJKLMNORTUVYZ]|T[CDFGHJKLMNOPRTVWZ]|
            U[AGKMSYZ]|V[ACEGINU]|W[FS]|Y[ETU]|Z[AMW])
    )
    (?:$|\s)
)
# based on http://daringfireball.net/2010/07/improved_regex_for_matching_urls
# and http://stackoverflow.com/questions/1141848/regex-to-match-url