check for alphanumeric characters
Mark Waddingham
36degrees at runrev.com
Thu Mar 3 07:21:04 EST 2005
Hi Nicolas,
> Is there a Rev function for checking whether a variable contains only
> letters and/or numbers? When using clickChunk, I want anything not a word to
> be ignored (e.g., punctuation).
I think a Regular Expression is what you need. Try:
if matchText(tText, "^[0-9A-Za-z]+$") then
answer "It's alphanumeric :o)"
else
answer "It's not alphanumeric :o("
end if
If you haven't come across Regular Expressions before, they are a good
thing to have in your toolbox since they can help with many text-
processing tasks.
Revolution uses Perl-style expressions and as such there is a great deal
of literature on the internet about them, for example:
http://gnosis.cx/publish/programming/regular_expressions.html
This is quite a nice walk-through of numerous example of them - although
being directed at Perl, you have to remember to read /[a-z]/ as "[a-z]".
('/' is Perl's regular expression syntax, but in Revolution REs are done
via the matchText and related functions that just take an RE as a
string)
Warmest Regards,
Mark.
------------------------------------------------------------------
Mark Waddingham ~ 36degrees at runrev.com ~ http://www.runrev.com
Runtime Revolution ~ User-Centric Development Tools
More information about the use-livecode
mailing list