| View previous topic :: View next topic |
| Author |
Message |
doggo Halfop
Joined: 05 Jan 2010 Posts: 97
|
Posted: Tue Jul 13, 2010 1:45 pm Post subject: [solved] regexp or regsub im lost |
|
|
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  _________________ 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 |
|
 |
speechles Revered One

Joined: 26 Aug 2006 Posts: 1398 Location: emerald triangle, california (coastal redwoods)
|
Posted: Tue Jul 13, 2010 8:15 pm Post subject: |
|
|
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  _________________ speechles' eggdrop tcl archive |
|
| Back to top |
|
 |
doggo Halfop
Joined: 05 Jan 2010 Posts: 97
|
Posted: Wed Jul 14, 2010 8:59 am Post subject: |
|
|
| Code: | regsub -all {\{} $search "" search_clean
regsub -all {\}} $search_clean "" search_even_clean |
fixed it  _________________ NON geeky!! http://gotcode4u.com/ |
|
| Back to top |
|
 |
Luminous Op
Joined: 12 Feb 2010 Posts: 146
|
Posted: Tue Aug 10, 2010 5:24 pm Post subject: |
|
|
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 |
|
 |
|