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 

return 0 by number

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


Joined: 21 May 2008
Posts: 8

PostPosted: Wed May 21, 2008 3:03 pm    Post subject: return 0 by number Reply with quote

I am looking for the code that will return 0, if the $text contains one or more of the numbers: 1234567890 and/or a . (dot)

tnx
Back to top
View user's profile Send private message
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Wed May 21, 2008 3:27 pm    Post subject: Reply with quote

Code:
return [expr {![string match {*[0-9.]*} $text]}]

_________________
Follow me on GitHub

- Opposing

Public Tcl scripts
Back to top
View user's profile Send private message Visit poster's website
Papillon
Owner


Joined: 15 Feb 2002
Posts: 724
Location: *.no

PostPosted: Wed May 21, 2008 4:08 pm    Post subject: Reply with quote

or do:
Code:
if {[regexp {[1-9]|\.} $text]} { return 0 }


difference being that in Sir_Fz example you get the return 1 when no match is made. Of course you can just toss the string match into an if statement as I have done and get the desired result. Just wanted to show it done with regexp
_________________
Elen sila lúmenn' omentielvo
Back to top
View user's profile Send private message MSN Messenger
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Wed May 21, 2008 6:01 pm    Post subject: Reply with quote

Papillon wrote:
or do:
Code:
if {[regexp {[1-9]|\.} $text]} { return 0 }

You forgot the 0, it can also be done like this using regexp:
Code:
regexp {[0-9.]} $text

_________________
Follow me on GitHub

- Opposing

Public Tcl scripts
Back to top
View user's profile Send private message Visit poster's website
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