egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

regsub problems.

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
iamdeath
Master


Joined: 11 Feb 2005
Posts: 323
Location: *HeLL*

PostPosted: Tue Mar 13, 2007 9:42 pm    Post subject: regsub problems. Reply with quote

Hi, I have tried to write a code which will fetch cricket scores from a webpage and will show it to any channel.

The weblink of Score:

Scores

The regsub I am using:

Code:

    regsub -all "\n" $body "" body
    regsub -all -nocase {<br>} $body "<br>\n" body
    regsub -all {<b>} $body "\n\002" body
    regsub -all {</b>} $body "\002" body
    regsub -all {World Cup Warm-up Matches} $body "\00304,01World Cup Warm-up Matches\003" body
    regsub -line {<p class="blueBackHeading">} $body "\n\00304,01" body
    regsub -line {</p>} $body "\003\n" body
    regsub -all {<.+?>} $body "" body
    regsub -all {&nbsp;} $body "" body
    regsub -all {This page automatically refreshes every 60 seconds.} $body "" body
    regsub -all {Scorecard} $body "" body
    regsub -all {Desktop scorecard} $body "" body
    regsub -all {Bulletin} $body "" body
    regsub -all {|  |} $body "" body

   


The Reply I am getting:

Code:

[06:33] <Cricket`->         
[06:33] <Cricket`-> Current time:01:33 GMT, Wed Mar 14, 2007
[06:33] <Cricket`-> 04,01One-Day Internationals
[06:34] <Cricket`-> 1st Match, Group D: West Indies v Pakistan at Kingston - Mar 13, 2007
[06:34] <Cricket`-> West Indies won by 54 runs
[06:34] <Cricket`-> West Indies 241/9 (50 ov); Pakistan 187 (47.2 ov) |  |  |  | Standard Bank Pro20 Series
[06:34] <Cricket`-> Titans v Dolphins at Benoni - Mar 14, 2007
[06:34] <Cricket`-> Match scheduled to begin at 18:00 local time (16:00 GMT)
[06:34] <Cricket`-> Warriors v Lions at East London - Mar 14, 2007
[06:34] <Cricket`->


Need help:

1. I want to get rid of pipes " | "
2. You see that " Standard Bank Pro20 Series " is the heading it should come on a different line but it's not coming.
3. At the start and the end there is a blank space
4. The last line from the web the bot did'nt show.

Can you kindly help me out, I've tried to read regsub help alot but can't get outta it. Your help will be appreciated.

Thanks.
Back to top
View user's profile Send private message Visit poster's website
rosc2112
Revered One


Joined: 19 Feb 2006
Posts: 1454
Location: Northeast Pennsylvania

PostPosted: Wed Mar 14, 2007 12:03 am    Post subject: Reply with quote

Why not use regexp to get the lines you DO want, instead of regsub'ing the junk you don't? Then you can put things into seperate vars, like for the titles and such. And then you can put your color codes into the var strings. You can use string trim to get rid of extra spaces..

Code:

regexp {<span.*?>Current time:</span>.*<span.*?>(.*?)</span>.*?<p class.*?>One-Day Internationals</p><p.*?>(.*?)</p>.*?<p.*?>Standard Bank Pro20 Series</p><p.*?>(.*?)</p>} body match date odiscores sbp20scores
#antiwordwrap---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

That will put the relevant data into the vars called $date $odiscores and $sbp20scores. Then you can use regsub to get rid of \n, <b> and <br> (or use string map, either way you can put color codes in the strings if you want.)

The regexp hasn't been tested but should work. Read the regexp manpage, and notice the () parts are what are going to be put into the variable names. The var $match is the entire string.
Back to top
View user's profile Send private message
iamdeath
Master


Joined: 11 Feb 2005
Posts: 323
Location: *HeLL*

PostPosted: Wed Mar 14, 2007 4:32 pm    Post subject: Reply with quote

Thanks, I'll use and let you know if I have any problems..
Back to top
View user's profile Send private message Visit poster's website
rosc2112
Revered One


Joined: 19 Feb 2006
Posts: 1454
Location: Northeast Pennsylvania

PostPosted: Wed Mar 14, 2007 11:20 pm    Post subject: Reply with quote

I just noticed I had 'body' instead of $body in that example, should be

regexp {expression} $body match etc etc etc
Back to top
View user's profile Send private message
iamdeath
Master


Joined: 11 Feb 2005
Posts: 323
Location: *HeLL*

PostPosted: Fri Mar 16, 2007 9:33 pm    Post subject: Reply with quote

Thanks for your kind, actually I have;nt yet got it done.. but I wanted to ask you if I only want to get ride of "|" can i get rid of them through regsub or regexp?..

Thanks
Back to top
View user's profile Send private message Visit poster's website
rosc2112
Revered One


Joined: 19 Feb 2006
Posts: 1454
Location: Northeast Pennsylvania

PostPosted: Fri Mar 16, 2007 11:16 pm    Post subject: Reply with quote

Yes, regsub would work, but it would have to be escaped, as

regsub -all {\|} $varname {} varname
Back to top
View user's profile Send private message
iamdeath
Master


Joined: 11 Feb 2005
Posts: 323
Location: *HeLL*

PostPosted: Sat Mar 17, 2007 8:36 am    Post subject: Reply with quote

Thanks alot Smile

I am done with the pipes atleast Razz
Back to top
View user's profile Send private message Visit poster's website
CuteBangla
Halfop


Joined: 27 Feb 2006
Posts: 58
Location: Dhaka, Bangladesh

PostPosted: Sun Mar 18, 2007 7:44 am    Post subject: Reply with quote

iamdeath wrote:
Thanks alot Smile

I am done with the pipes atleast Razz


will you share the working script with us plz
_________________
SuMiT
iRC.CuteBangla.Com
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber