This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Regexp

Old posts that have not been replied to for several years.
Locked
t
t3ch^
Voice
Posts: 16
Joined: Sat Dec 27, 2003 7:19 pm

Regexp

Post by t3ch^ »

I got a problem with regexp.

I got this code from a web page:

Code: Select all

<a href="http://uk.weather.yahoo.com/Europe/United_Kingdom/England/">
<a href="http://uk.weather.yahoo.com/UKXX/UKXX0085/index_c.html">
I want to extract:

Code: Select all

UKXX/UKXX0085
But with this regexp:

Code: Select all

regexp -nocase {<a href="http://uk.weather.yahoo.com/(.*?)/index_c.html">} $data data match
My match result is:

Code: Select all

Europe/United_Kingdom/England/">
Full code:

Code: Select all

package require http
bind pub - !weather www:weather
proc www:weather {nick host handle chan text} {
        set query $text
        set data [http::data [http::geturl http://uk.search.weather.yahoo.com/search/weather_ukie?p=$query]]
        regexp {<a href="http://uk.weather.yahoo.com/(.*?)/index_c.html">} $data data match
        puthelp "PRIVMSG $chan :$match"
}
t
t3ch^
Voice
Posts: 16
Joined: Sat Dec 27, 2003 7:19 pm

Post by t3ch^ »

I got it working with this:

Code: Select all

regexp {<a href="http://uk.weather.yahoo.com/([a-zA-Z0-9]*)/([a-zA-Z0-9]*)/index_c.html">} $data data match match2
But im not sure of its the right way to do it...
//
User avatar
Papillon
Owner
Posts: 724
Joined: Fri Feb 15, 2002 8:00 pm
Location: *.no

Post by Papillon »

ermm.. the first regexp works fine...
from my tclsh:
Elen sila lúmenn' omentielvo
Locked