On 1/25/06 11:20 AM, "Martin Baxter" <[EMAIL PROTECTED]> wrote:
> 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.
Looks good, Martin, but if the original intention is "isValid", not
"isNotValid", I'd personally remove the "double-negatives":
function isvalid mystring
return (matchtext(mystring,"^[a-zA-Z0-9_]+$"))
end isvalid
The other possibility, if you want to depend on what PCRE's character
matching table says, is to use the "any 'word' character" option \w:
function isvalid mystring
return (matchtext(mystring,"^\w+$"))
end isvalid
The docs (at http://www.pcre.org/man.txt) says this about \w:
A "word" character is any letter or digit or the underscore
character, that is, any character which can be part of a Perl
"word". The definition of letters and digits is controlled by
PCRE's character tables, and may vary if local-specific
matching is taking place. For exaemple, in the "fr" (French)
locale, some character codes greater than 128 are used for
accented characters and there are matched by \w.
Anyway, my 2 cents...
Ken Ray
Sons of Thunder Software
Web site: http://www.sonsothunder.com/
Email: [EMAIL PROTECTED]
_______________________________________________
use-revolution mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution