| View previous topic :: View next topic |
| Author |
Message |
droolin Halfop

Joined: 24 Jul 2003 Posts: 64
|
Posted: Mon Sep 17, 2007 8:26 pm Post subject: How to acquire the number of characters minus color codes |
|
|
Is there a way to count the number of characters in a string minus the hex codes for colors?
| Quote: | | "\0034,1\xb0\xbaO\xa7\0030 ~ ~ ~ ~ ~ $botnick command help ~ ~ ~ ~ ~ " |
If I do a string length on that, that returns the total count of characters including the hex values and such. Is there any way to only only get a length of printable characters including the subst value of $botnick.
drool |
|
| Back to top |
|
 |
rosc2112 Revered One

Joined: 19 Feb 2006 Posts: 1454 Location: Northeast Pennsylvania
|
Posted: Tue Sep 18, 2007 12:09 am Post subject: |
|
|
| Of course there's a way, strip off the stuff you don't want with either regsub or the stripcodes commands then use string length |
|
| Back to top |
|
 |
awyeah Revered One

Joined: 26 Apr 2004 Posts: 1580 Location: Switzerland
|
Posted: Tue Sep 18, 2007 2:28 am Post subject: |
|
|
If $text is "\0034,1\xb0\xbaO\xa7\0030 ~ ~ ~ ~ ~ $botnick command help ~ ~ ~ ~ ~"
then:
| Code: |
#In eggdrop 1.6.17 and later, you can use:
set text [stripcodes bcruag $text]
#If you want to count spaces as characters
set textlen [string length $text]
#If you don't want to count spaces as characters
set textlen [string length [string map {" " ""} $text]]
|
_________________ ·awyeah·
==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
================================== |
|
| Back to top |
|
 |
|