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.

special char in 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

special char in regexp

Post by t3ch^ »

i have this script:

Code: Select all

# We need http package
#package req http

bind pub - !tv info:tv
proc info:tv {nick host handle chan text} {
	set url "http://tvprogram.nu/cgi-tvprogram/pp1.cgi?NU-palmpilot.htm"
	set data [http::data [http::geturl $url]]

	if {![regexp -nocase {<b>SVT1</b>(.*?)<b>([0-9\.]+) ([0-9a-zA-ZåäöÅÄÖ\-\.\,\?\:\'\&\n ]*)</b>} $data data2 ok time1 tv1]} {set tv1 "?"; set time1 "?"}
	if {![regexp -nocase {<b>SVT2</b>(.*?)<b>([0-9\.]+) ([0-9a-zA-ZåäöÅÄÖ\-\.\,\?\:\'\&\n ]*)</b>} $data data2 ok time2 tv2]} {set tv2 "?"; set time2 "?"}
	if {![regexp -nocase {<b>TV3 SVERIGE</b>(.*?)<b>([0-9\.]+) ([0-9a-zA-ZåäöÅÄÖ\-\.\,\?\:\'\&\n ]*)</b>} $data data2 ok time3 tv3]} {set tv3 "?"; set time3 "?"}
	if {![regexp -nocase {<b>TV4</b>(.*?)<b>([0-9\.]+) ([0-9a-zA-ZåäöÅÄÖ\-\.\,\?\:\'\&\n ]*)</b>} $data data2 ok time4 tv4]} {set tv4 "?"; set time4 "?"}
	if {![regexp -nocase {<b>TV4\+</b>(.*?)<b>([0-9\.]+) ([0-9a-zA-ZåäöÅÄÖ\-\.\,\?\:\'\&\n ]*)</b>} $data data2 ok time5 tv5]} {set tv5 "?"; set time5 "?"}
	if {![regexp -nocase {<b>KANAL5</b>(.*?)<b>([0-9\.]+) ([0-9a-zA-ZåäöÅÄÖ\-\.\,\?\:\'\&\n ]*)</b>} $data data2 ok time6 tv6]} {set tv6 "?"; set time6 "?"}
	if {![regexp -nocase {<b>ZTV</b>(.*?)<b>([0-9\.]+) ([0-9a-zA-ZåäöÅÄÖ\-\.\,\?\:\'\&\n ]*)</b>} $data data2 ok time7 tv7]} {set tv7 "?"; set time7 "?"}

	set svt1 [lindex [split $tv1 \n] 0]
	set svt2 [lindex [split $tv2 \n] 0]
	set tv3 [lindex [split $tv3 \n] 0]
	set tv4 [lindex [split $tv4 \n] 0]
	set tv42 [lindex [split $tv5 \n] 0]
	set kanal5 [lindex [split $tv6 \n] 0]
	set ztv [lindex [split $tv7 \n] 0]

	puthelp "PRIVMSG $chan :\002SVT1:\002 \[${time1}\] $svt1 \002SVT2:\002 \[${time2}\] $svt2 \002TV3:\002 \[${time3}\] $tv3"
	puthelp "PRIVMSG $chan :\002TV4:\002 \[${time4}\] $tv4 \002TV4+:\002 \[${time5}\] $tv42 \002KANAL5:\002 \[${time6}\] $kanal5 \002ZTV:\002 \[${time7}\] $ztv" } 
working prety nice. but now i noticed a bug. it doesnt work with ü
i changed this code: ([0-9a-zA-ZåäöÅÄÖ\-\.\,\?\:\'\&\n ]*)
to: ([0-9a-zA-ZåäöÅÄÖ\-\.\,\?\:\'\&\n\ü ]*)

result: Tcl error [info:tv]: couldn't compile regular expression pattern: invalid escape \ sequence

pls hilfi :)
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

Yeah I know... take a look at this thread
carefully and read it all the way through.

At the bottom you would find the working result.


http://forum.egghelp.org/viewtopic.php? ... ight=ascii

If you want to add special characters and ascii codes
do the way I have done in that thread.
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
Locked