Forked from gruber/Liberal Regex Pattern for All URLs
Created
December 8, 2009 19:51
-
-
Save karbassi/251928 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(?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