MACSCRPT Archives

December 2006

MACSCRPT@LISTSERV.DARTMOUTH.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Emmanuel <[log in to unmask]>
Reply To:
Macintosh Scripting Systems <[log in to unmask]>
Date:
Mon, 4 Dec 2006 23:22:15 +0100
Content-Type:
text/plain
Parts/Attachments:
text/plain (48 lines)
At 3:54 PM -0500 12/4/06, Jeramey Valley wrote:
>I have a list of email addresses*. Some of the addresses in the list 
>are not of correct form, meaning they may have a space, extra period 
>or other no-no in the address.
>
>Examples:
>
>someDude@gmail..com
>my name@my company.com
>
>What's the best way to test and fix the errors in this list?
>
>My plan was to use the regex function in the Satimage addition and 
>perform a pattern replace. I would be creating the pattern from 
>scratch.
>
>Has anyone gone through and created the most common pattern matches 
>they would like to share or have a better solution?

I would advise using Apple's strategy, which checks first that it 
"looks like" an e-mail address, then searches for gremlins. That's at 
<http://developer.apple.com/internet/webcontent/validation.html>, but 
it's javascript.

We use the following variante:

on isvalidemail(x)
	try
		ufind text "[log in to unmask]\\..{2,3}$" in x with regexp
	on error
		return false
	end try

	try
		ufind text 
"[áàâäéèêëíìîïóòôöúùûüÿ()<>,;:\\\\/\"\\[\\]]" in x with regexp
		return false
	end try

	return true
end isvalidemail


Be aware that nothing is easier than finding lots of invalid 
addresses which will return true: for instance, addresses with kanji.

Emmanuel

ATOM RSS1 RSS2