Checking legality of a string
Martin Baxter
mb.ur at harbourhost.co.uk
Wed Jan 25 12:20:56 EST 2006
Eric Chatonet wrote:
> Hi Graham,
> I think that there should be also a solution using matchText :-)
> Le 25 janv. 06 à 16:25, graham samuel a écrit :
>
>> What's the most economical way of checking that a string contains
>> only certain characters? I'm just trying to check if a string
>> contains letters, digits and underscores, and nothing else. The ways
>> I've thought of doing it seem clunky. Basically I want to script
or try...
function isvalid mystring
return not (matchtext(mystring,"[^a-zA-Z0-9_]+?"))
end isvalid
# there is a match if any character other than a-z A-Z 0-9 or _ is found
# in mystring
# using not inverts the result so that the function returns true
# if the string is valid.
Martin Baxter
More information about the use-livecode
mailing list