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 

regexp matching with a $string

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


Joined: 29 Jan 2006
Posts: 8

PostPosted: Thu Feb 09, 2006 2:16 am    Post subject: regexp matching with a $string Reply with quote

I have a $string that contains a bunch of special characters that regexp will pick up as expressions... so how can I do...

if {[regexp $string $matchstring]} { ... }

since that won't work, what i am looking for is a way to negate expressions like \. for a period but for the entire $string to make it literal.
Back to top
View user's profile Send private message
Ofloo
Owner


Joined: 13 May 2003
Posts: 953
Location: Belguim

PostPosted: Mon Feb 27, 2006 4:09 pm    Post subject: Reply with quote

This is a proc that will return <number of special chars> on special chars and 0 on alphabetic and nummeric chars..


Code:
proc special {arg} {
  if {[regexp -nocase -all {[^a-z0-9]} $string -> n]} {
    return $n
  }
  return 0
}

_________________
XplaiN but think of me as stupid
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