R
Ruby Baby
Ugly:
class String
def hyperlink
gsub(/(http:\/\/|https:\/\/|mailto([[:alnum:]\/!\#$\%&'()*+,.:;=?@~-]+)([[:alnum:]\/!\#$\%&'()*+:;=?@~-])/, '<a href="\\1\\2\\3">\\1\\2\\3</a>')
end
end
... but it generally works, from my few tests.
Anyone got a better version, or care to improve on this one?
Just trying to hyperlink URLs in text (and in future, email addresses, without needing mailto.
class String
def hyperlink
gsub(/(http:\/\/|https:\/\/|mailto([[:alnum:]\/!\#$\%&'()*+,.:;=?@~-]+)([[:alnum:]\/!\#$\%&'()*+:;=?@~-])/, '<a href="\\1\\2\\3">\\1\\2\\3</a>')
end
end
... but it generally works, from my few tests.
Anyone got a better version, or care to improve on this one?
Just trying to hyperlink URLs in text (and in future, email addresses, without needing mailto.