# URI.regexp buggy for detecting links?

**URL:** <https://www.ruby-forum.com/t/uri-regexp-buggy-for-detecting-links/175696>\
**Category:** Ruby\
**Created:** [September 17, 2009, 10:06pm UTC](https://www.ruby-forum.com/t/uri-regexp-buggy-for-detecting-links/175696 "2009-09-17T22:06:16Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![pure](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/3ab097/32.png) [@pure](https://www.ruby-forum.com/u/pure)\
**Post date:** [September 17, 2009, 10:06pm UTC](https://www.ruby-forum.com/t/uri-regexp-buggy-for-detecting-links/175696/1 "2009-09-17T22:06:16Z")

</div>

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](http://www.link.com)), the closing bracket is also formatted as link. So  
the link looks like \<a href=“[http://www.link.com](http://www.link.com))”…

How do you detect and format links in a text?

Thanks for help!
