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.

regsub ...?

Old posts that have not been replied to for several years.
Locked
T
TC^

regsub ...?

Post by TC^ »

I need to parse information from a simple HTML file...

I've tried looking through google.tcl, and I must confess, it's a little too complicated for me..

However I've found another script that was far more simple, but not nearly as advanced, and therefore more difficult to get to do what I want..

Code: Select all

set radio_url "http://213.114.155.110:8000/7.html"

bind pub - !users users_get

proc users_get {nick mask hand chan args} {
	global radio_url
	set file [open "|lynx -source $radio_url" r]
	set html "[gets $file]"
	regsub "<HTML><meta http-equiv=\"Pragma\" content=\"no-cache\"></head>" $html "" html
      regsub "<body>" $html "\002 Listeners: \002" html
	putchan $chan $html
}
The webpage is following:
<HTML><meta http-equiv="Pragma" content="no-cache"></head><body>4,1,8,80,4,128,Fpu - Racer Car (Voidcom)</body></html>
And the script returns:
Listeners: 4,1,8,80,4,128,Fpu - Racer Car (Voidcom)</body></html>
My question is... Can regsub be used in such a way, that it ignores all text from the first comma and forward.. So it returns this:
Listeners: 4
Help! :D
User avatar
Papillon
Owner
Posts: 724
Joined: Fri Feb 15, 2002 8:00 pm
Location: *.no

Post by Papillon »

Code: Select all

set html [lindex [split $html ,] 0]
add this line right above the putchan command...
Elen sila lúmenn' omentielvo
T
TC^

Post by TC^ »

Thanks! Worked just fine...

A little wuick question... What if I wanted to go the other way?
Listeners: 4,1,8,80,4,128,Fpu - Racer Car (Voidcom)</body></html>
Have it return from Fpu - Racer Car and forward? And not whats behind...?

Can you reverse it somehow ?

The number 128 is static!
Papillon wrote:

Code: Select all

set html [lindex [split $html ,] 0]
add this line right above the putchan command...
User avatar
Papillon
Owner
Posts: 724
Joined: Fri Feb 15, 2002 8:00 pm
Location: *.no

Post by Papillon »

Code: Select all

set html [lrange [split $html ,] 6 end]
the simplest way :)
Elen sila lúmenn' omentielvo
Locked