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 

How to acquire the number of characters minus color codes

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


Joined: 24 Jul 2003
Posts: 64

PostPosted: Mon Sep 17, 2007 8:26 pm    Post subject: How to acquire the number of characters minus color codes Reply with quote

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
View user's profile Send private message Visit poster's website
rosc2112
Revered One


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

PostPosted: Tue Sep 18, 2007 12:09 am    Post subject: Reply with quote

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
View user's profile Send private message
awyeah
Revered One


Joined: 26 Apr 2004
Posts: 1580
Location: Switzerland

PostPosted: Tue Sep 18, 2007 2:28 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
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