| View previous topic :: View next topic |
| Author |
Message |
stilllearning Voice
Joined: 29 Jan 2006 Posts: 8
|
Posted: Thu Feb 09, 2006 2:16 am Post subject: regexp matching with a $string |
|
|
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 |
|
 |
Ofloo Owner
Joined: 13 May 2003 Posts: 953 Location: Belguim
|
Posted: Mon Feb 27, 2006 4:09 pm Post subject: |
|
|
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 |
|
 |
|