Extract URLs from text using Ruby while handling matched parens

Posted by Horace Loeb on Stack Overflow See other posts from Stack Overflow or by Horace Loeb
Published on 2010-06-08T00:28:08Z Indexed on 2010/06/08 0:32 UTC
Read the original article Hit count: 230

Filed under:
|
|

URI.extract claims to do this, but it doesn't handle matched parens:

>> URI.extract("text here (http://foo.example.org/bla) and here")
=> ["http://foo.example.org/bla)"]

What's the best way to extract URLs from text without breaking parenthesized URLs (which users like to use)?

© Stack Overflow or respective owner

Related posts about ruby

Related posts about url