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 

[solved] regexp or regsub im lost

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


Joined: 05 Jan 2010
Posts: 97

PostPosted: Tue Jul 13, 2010 1:45 pm    Post subject: [solved] regexp or regsub im lost Reply with quote

my bot reads from a db and returns the info in channel, only problem is if $line has ...'s and or -_ it displays ok in the channel

but if $line contains spaces instead of ...'s and or -_ i get { $line }

heres an example hope someone can help, been messing around and googleing for ages....

#with the spaces it returns $line with { } either end

Code:
Thanks:(hl) You have been marked as FiLLING ReqId:(64) For:( full  {this is an example} )


and when there is ....'s and -_'s in it doesnt have the { }'s either end

Code:
Thanks:(hl) You have been marked as FiLLING ReqId:(64) For:( full  this.is.an-example )



thanks all hope i gave enough info Smile
_________________
NON geeky!! http://gotcode4u.com/


Last edited by doggo on Wed Jul 14, 2010 9:01 am; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website
speechles
Revered One


Joined: 26 Aug 2006
Posts: 1398
Location: emerald triangle, california (coastal redwoods)

PostPosted: Tue Jul 13, 2010 8:15 pm    Post subject: Reply with quote

Somewhere you've confused a tcl-list as a string.

Try using:
regexp {regexp here} [join $var] - var

Wrap a join around your $var-iable inside the regular expression. If this fixes it, then you know you have a tcl-list vs string issue. Don't use this as a permanent fix, find the issue and correct it. This is merely to test if indeed it is a list being treated as a string causing the problem.

Report back if you need more help Wink
_________________
speechles' eggdrop tcl archive
Back to top
View user's profile Send private message
doggo
Halfop


Joined: 05 Jan 2010
Posts: 97

PostPosted: Wed Jul 14, 2010 8:59 am    Post subject: Reply with quote

Code:
regsub -all {\{} $search "" search_clean
regsub -all {\}} $search_clean "" search_even_clean


fixed it Smile
_________________
NON geeky!! http://gotcode4u.com/
Back to top
View user's profile Send private message Visit poster's website
Luminous
Op


Joined: 12 Feb 2010
Posts: 146

PostPosted: Tue Aug 10, 2010 5:24 pm    Post subject: Reply with quote

That's not so much a fix as it is a band-aid. You should avoid doing a filter like that unless all else fails. Whenever you declare something as a list, each list element is separated by what is in {}. So if you declare set something [lindex $var 0], you'd get the first bit in {}. But if you don't output this correctly, the {} remains in the text. This is why you use join, to turn it back into a string, thus dropping the {} from the text automatically.

There is an article "How to write scripts that won't choke on special chars", but my net is too crappy atm to find it. :S
Back to top
View user's profile Send private message
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