Created
April 8, 2010 16:24
-
-
Save samsonjs/360240 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
urlRegex = /\b // 1. match a word boundary, i.e. whitespace or punctuation | |
( // 2. capture the entire URL | |
( [\w-]+:\/\/? | www[.] ) // 3. protocol:// or www. | |
[^\s()]+ // 4. anything that's not whitespace, a paren, or an angle bracket | |
(?: // 5. non-capturing group (this is the last thing matched) | |
\([\w\d]+\) // 6. trailing parenthesized word containing only alnums (wikipedia) | |
| // or | |
( [^-!"#$%&'()*+,./:;?@[\\\]^_`{|}~\s] // 7. [^[:punct:]\s] -- anything but punctuation or whitespace | |
| // or | |
\/ // 8. a trailing slash | |
) | |
) | |
) | |
/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment