URI.regexp buggy for detecting links?

Hey list,

we use URI.regexp([‘ftp’,‘http’,‘https’,‘ftp’,‘mailto’,‘see’]) to detect
links in a text.

But if a link is entered with brackets e.g. this is a text
(http://www.link.com), the closing bracket is also formatted as link. So
the link looks like <a href=“http://www.link.com)”…

How do you detect and format links in a text?

Thanks for help!