Does this string contain any character in a list of known bad
characters?
OR
Does this string contain any character besides [A-Za-z0-9], and
does it begin with a digit?
Both of which are easily accomplished using regular expressions. With
Satimage.osax installed:
find text "[ _<>()*~-]" in stringToSearch regexp true
will return a result if one of the characters between the brackets*
is in stringToSearch. And:
find text "^[0-9][A-Za-z0-9]+$" in stringToSearch regexp true
will return a result only if stringToSearch is alphanumeric, starting
with a digit.
In both cases, the "find text" command throws an error if no match is
found. So if you're only interested in a boolean result you could
trap for an error in each case. For instance:
try
find text "[ _<>()*~-]" in stringToSearch regexp true
set badCharsFound to true
on error
set badCharsFound to false
end try