These snippets of code can be used to check if an URL is valid or not and with some changes it can get URL's from a text.
# # Check if an URL is valid or not... # set blabla {http://www.ietf.org/rfc/rfc3986.txt} if {[regexp -- {^(https?://[a-z0-9\-]+\.[a-z0-9\-\.]+(?:/|(?:/[a-zA-Z0-9!#\$%&'\*\+,\-\.:;=\?@\[\]_~]+)*)))$} $blabla match url]} { puts "$url is a valid url." } # # Getting an URL from a HTML code... # set blabla {<div class="title">Edit <a href="http://wiki.tcl.tk/26255">URL Parser</a></div>} if {[regexp -- {(https?://[a-z0-9\-]+\.[a-z0-9\-\.]+(?:/|(?:/[a-zA-Z0-9!#\$%&'\*\+,\-\.:;=\?@\[\]_~]+)*)))} $blabla match url]} { puts "$url found in the HTML code." }
Let's test it and post the results here...
PS: It doesn't work for IPv6 yet.