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.
Help for those learning Tcl or writing their own scripts.
pinkel
Voice
Posts: 8 Joined: Wed May 21, 2008 2:59 pm
Post
by pinkel » Wed May 21, 2008 3:03 pm
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
Sir_Fz
Revered One
Posts: 3794 Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:
Post
by Sir_Fz » Wed May 21, 2008 3:27 pm
Code: Select all
return [expr {![string match {*[0-9.]*} $text]}]
Papillon
Owner
Posts: 724 Joined: Fri Feb 15, 2002 8:00 pm
Location: *.no
Post
by Papillon » Wed May 21, 2008 4:08 pm
or do:
Code: Select all
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
Sir_Fz
Revered One
Posts: 3794 Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:
Post
by Sir_Fz » Wed May 21, 2008 6:01 pm
Papillon wrote: or do:
Code: Select all
if {[regexp {[1-9]|\.} $text]} { return 0 }
You forgot the 0, it can also be done like this using regexp: