Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save planbnet/249798 to your computer and use it in GitHub Desktop.
Save planbnet/249798 to your computer and use it in GitHub Desktop.
(?x)
\b
( # Capture 1: entire matched URL
(?:
[\w-]+: # URL protocol and colon
(?:
/{1,3} # 1-3 slashes
| # or
[[:alpha:][:digit:]] # Single letter or digit
# (Try not to match, say "URI::Escape")
)
| # or
www\d?[.] # "www.", "www1.", "www2.", etc.
)
(?: # One or more:
[^\s()<>]+ # Run of non-space, non-()<>
| # or
\([^\s()<>]+\) # a matching set of parens
)+
(?: # End with:
\([^\s()<>]+\) # a set of parens
| # or
(?:
[^[:punct:]\s] # a non-punctuation non-space char
| # or
/ # a slash
)
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment