This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

counter

Old posts that have not been replied to for several years.
Locked
s
sith
Voice
Posts: 5
Joined: Wed May 11, 2005 8:23 am

counter

Post by sith »

Where can I find a counter for counting number of words letters, smilies which was sent on the chanel by every user?
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

I don't beleive you can find a counter, but here a simple examples:

Code: Select all

#This will count total characters than alphabets and words including them also
set total_characters [string length [string map {" " ""} $text]]
set total_characters [string length [string trim $text]]
or
#This will only count total alphabets and words
set total_characters [regexp -all -nocase {[A-Z][0-9]} $text]

set total_alphabets [regexp -all -nocase {[A-Z]} $text]
set total_numbers [regexp -all {[0-9]} $text]

set total_words [llength $text]

#To count smilies
set total_smiles [regexp -all {:)} $text]
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Edit: Bogus info.
Last edited by Sir_Fz on Sat May 14, 2005 7:05 pm, edited 1 time in total.
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

These 2 seem to work:

Code: Select all

<awyeah> .tcl regexp -all {[A-Z]} "QWRDFGDSGER86574575HDFGF"
<adapter> Tcl: 16

<awyeah> .tcl regexp -all {[0-9]} "QWRDFGDSGER86574575HDFGF"
<adapter> Tcl: 8
This one doesn't

Code: Select all

<awyeah> .tcl regexp -all -nocase {[A-Z][0-9]} "QWRDFGDSGER86574575HDFGF"
<adapter> Tcl: 1

#But you can count [A-Z] and [0-9] seperately above and add them with expr.

set total_characters [expr [regexp -all {[A-Z]} $text] + [regexp -all {[0-9]} $text]]
And this works too:

Code: Select all

<awyeah> .tcl regexp -all {:\)} "QWRDFGDSGER86574575HDFGF:):):)"
<adapter> Tcl: 3
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Oh yeah, the '-all' switch (sorry for my stupidity).

for the second one, you can use:

Code: Select all

set total_characters [regexp -all -nocase {[A-Z]|[0-9]} $text]
or you can remove the -nocase switch and use:

Code: Select all

set total_characters [regexp -all {[A-z]|[0-9]} $text]
Locked