johnlopez2000
Programmer
I am attempting to use to create a function that will let me determine if there:
-hasalpha
-hasnumeric
properties inthe string.
This would be used to test a string for "purity", ie: determining if a string has mixed alpha-numeric chars.
I thought I could use STRING MATCH with a range of [0-9] to test for the presence of numeric chars, and STRING MATCH with a range of [A-Z] to test for the presence of some alpha chars. Have done similar with GREP.
However, when I attempt to use the braketed range:
% set x [string match [0-9] "0000"]
invalid command name "0-9"
TCL interprets the [] as containing an internal command. The TCL man page says:
string match pattern string
...
[chars] Matches any character in the set given
by chars. If a sequence of the form x-y
appears in chars, then any character
between x and y, inclusive, will match.
I've also attempted to use the SUBST command to overcome this:
set x [subst -nocommands {string match [0-9] "0000"}]
but all permutations that I've tried to then exec the above yield the same error.
Your suggestions are most appreciated.
John Lopez
Enterprise PDM & Integration Consulting
Development for MatrixOne PDM Systems
johnlopez2000@hotmail.com
-hasalpha
-hasnumeric
properties inthe string.
This would be used to test a string for "purity", ie: determining if a string has mixed alpha-numeric chars.
I thought I could use STRING MATCH with a range of [0-9] to test for the presence of numeric chars, and STRING MATCH with a range of [A-Z] to test for the presence of some alpha chars. Have done similar with GREP.
However, when I attempt to use the braketed range:
% set x [string match [0-9] "0000"]
invalid command name "0-9"
TCL interprets the [] as containing an internal command. The TCL man page says:
string match pattern string
...
[chars] Matches any character in the set given
by chars. If a sequence of the form x-y
appears in chars, then any character
between x and y, inclusive, will match.
I've also attempted to use the SUBST command to overcome this:
set x [subst -nocommands {string match [0-9] "0000"}]
but all permutations that I've tried to then exec the above yield the same error.
Your suggestions are most appreciated.
John Lopez
Enterprise PDM & Integration Consulting
Development for MatrixOne PDM Systems
johnlopez2000@hotmail.com