set xeurl "http://www.xe.com/ucc/convert.cgi"
set xequery [::http::formatQuery Amount "$amount" From "$fromcur" To "$tocur"]
catch {set page [::http::geturl $xeurl -query $xequery -timeout $xeutimeout]} error
if {[string match -nocase "*couldn't open socket*" $error]} {
puthelp "PRIVMSG $nick :Error: couldn't connect to XE.com..Try again later"
::http::cleanup $page
return
}
if { [::http::status $page] == "timeout" } {
puthelp "PRIVMSG $nick :Error: Connection timed out to XE.com."
::http::cleanup $page
return
}
set html [::http::data $page]
::http::cleanup $page
if {[regexp {>Live rates at (.*?)</span>} $html match xetime]} {
#some of the IF above has been deleted for this example
# manipulate the data:
regsub -all {<!.*?>} $fromamount {} fromamount
regsub -all {<!.*?>} $toamount {} toamount
puthelp "PRIVMSG $chan :XE.COM: \002$fromamount\002 equals \002$toamount\002 as of $xetime"
} else {
puthelp "PRIVMSG $chan :Could not obtain results from XE.com, sorry!"
}
Half right, half wrong...
. would match any character, and would survive not being escaped.
? however does not match any characters by itself, but is used to match 0 or 1 occurances of the prefixed atom (in this case the character p). In this case it must be escaped.