Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save karbassi/251928 to your computer and use it in GitHub Desktop.
Save karbassi/251928 to your computer and use it in GitHub Desktop.
(?xi)
\b
( # Capture 1: entire matched URL
(?:
[a-z][\w-]+: # URL protocol and colon
(?:
/{1,3} # 1-3 slashes
| # or
[a-z0-9%] # Single letter or digit or '%'
# (Trying not to match e.g. "URI::Escape")
)
| # or
www\d{0,3}[.] # "www.", "www1.", "www2." … "www999."
)
(?: # One or more:
[^\s()<>]+ # Run of non-space, non-()<>
| # or
\([^\s()<>]+\) # a matching set of parens
)+
(?: # End with:
\([^\s()<>]+\) # a set of parens
| # or
[^`!()\[\]{};:'".,<>?«»“”‘’\s] # not a space or one of these punct chars
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment