Re: Validating email address
Re: Validating email address
- Subject: Re: Validating email address
- From: has <email@hidden>
- Date: Sun, 4 Dec 2005 17:22:35 +0000
Bernardo H?hl wrote:
>Ol· Michael, tubo bem aqui, obrigado por escrever em portuguÍs.
>
>Thanks for posting.
>
>I tried not to put into my first post unneeded details, but I am
>building an AppleScript Studio application, so I would prefer to use
>plain vanilla applescript function (handler) instead of having to use
>another app, such as "TextCommands".
Use 'do shell script' to call into Perl/Python and use their regex support then. (Note that TextCommands' "check" command is itself just a wrapper around Python's built-in string method and re module.) You have to futz around yourself to keep right on text encodings, of course, and you've the usual limits on the amount of data you can pass on a shell command (but that won't matter in this case), and it'll be kinda slow if you're using it a lot, but it'll get the job done:
property _emailPatt : "[A-Z0-9._%-]+@[A-Z0-9._%-]+\\.[A-Z]{2,4}" -- junky pattern
set str to "email@hidden"
set isMatch to (do shell script ("python -c 'import sys, re; s = sys.argv[2].encode(\"utf8\"); match = re.compile(sys.argv[1].encode(\"utf8\"), re.U + re.I + re.S).match(s); print bool(match and match.end() == len(s))' " as Unicode text) & quoted form of _emailPatt & space & quoted form of str) is "True"
Or find yourself an ObjC re library and call into that via Studio's "call method" command. Or work out a suitable re pattern, then convert it into vanilla AS code (tedious, but doable).
HTH
has
--
http://freespace.virgin.net/hamish.sanderson/
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden