Deconstruction of a URL-matching regular expression.
This commit is contained in:
parent
fde52b4402
commit
f28ea1833a
@ -4,7 +4,33 @@ Linkify =
|
||||
|
||||
# gruber revised + magnet support
|
||||
# http://df4.us/fv9
|
||||
@catchAll = /\b([a-z][\w-]+:(\/{1,3}|[a-z0-9%]|\?(dn|x[lts]|as|kt|mt|tr)=)|www\d{0,3}\.|[a-z0-9.\-]+\.[a-z]{2,4}\/)([^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’])/g
|
||||
@catchAll = ///
|
||||
\b
|
||||
(
|
||||
[a-z][\w-]+: # URL protocol and colon
|
||||
(
|
||||
/{1,3} # 1-3 slashes
|
||||
| # or
|
||||
[a-z0-9%] # Single letter or digit or '%'
|
||||
| # or
|
||||
\?(dn|x[lts]|as|kt|mt|tr)= # Magnet parameters
|
||||
)
|
||||
| # 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()<>]+|(\([^\s()<>]+\)))*\) # balanced parens, up to 2 levels
|
||||
)+
|
||||
( # End with:
|
||||
\(([^\s()<>]+|(\([^\s()<>]+\)))*\) # balanced parens, up to 2 levels
|
||||
| # or
|
||||
[^\s`!()\[\]{};:'".,<>?«»“”‘’] # not a space or one of these punct chars
|
||||
)
|
||||
///g
|
||||
|
||||
Post::callbacks.push
|
||||
name: 'Linkify'
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user