How do I parse a string to find a URL?

J

Jayson Williams

Is there a command in Ruby that will accept a string, and spit out a
URL that is contained in the string? I think I remember reading about
something that would do this, but I cant recall.
 
F

franco

D

Daniel DeLorme

franco said:
not a weakness, in that string 'behold:' is a valid uri, it has a
scheme with a scheme delimeter (":"). "www.abc.com" is not an
unambiguous uri, no scheme present.

Is it a valid uri if nothing is present after the scheme? Anyway, I know
that the results are technically valid but they are less than useful if
you want, say, to extract and "linkify" urls that users might have
written inside a message. (which is what I assumed the OP wanted but I
might have been mistaken)

Daniel
 
F

franco

Is it a valid uri if nothing is present after the scheme? Anyway, I know
that the results are technically valid but they are less than useful if
you want, say, to extract and "linkify" urls that users might have
written inside a message. (which is what I assumed the OP wanted but I
might have been mistaken)

Daniel

you could just select the ones with a scheme scpecific part? or screen
scrape for //a/@href to get all hyperreferenced anchors (links).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,264
Messages
2,571,323
Members
48,007
Latest member
Elvis60357

Latest Threads

Top