regex - How to write reg expression which uses some special characters? -
i write reg expression should not use special symbols other (/, \, -, [, ], <, >, $, ~, !, @, #, :, %). try:
if { [regexp {^[\w/-\[\]<>$#~!@#%:\\\/]+$} $name] != 1 } { puts "handle error"; }
but not work.
for example such name io1??
it's not treated error
could help?
you have escape -
in character class or put @ beginning - otherwise it's interpreted range:
regexp {^[\w/\-\[\]<>$#~!@#%:\\\/]+$} $name
or
regexp {^[-\w/\[\]<>$#~!@#%:\\\/]+$} $name
the range between /
, \[
seems contain ?
.
Comments
Post a Comment