Forum Moderators: open
Does anyone know how to find and delete bad emails in a database. I know i can do a search for emails where the email NOT LIKE '%@%'.
I guess i could also do a search for those NOT lIKE '%.com', but that would also delete the .co.uk's, the .net's etc.
Does anyone know of a good way to do this, or is it really just a case of going through checking myself 1 by 1?
Webboy
you could make it run in a loop down your sql table and delete the row if not validated.
if you're interested i'll sticky mail it to ya.
a regular expression like this : ^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)¦(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}¦[0-9]{1,3})(\]?)$ would find virtual all errounous e-mail adresses. Unfortunately, just testing for invalid chars is not sufficient enough.
For example
joe.cool@hotmailcom shouldn't be accepted
Perform regular expression check on them.
If bad - put in a new "bad email" table.
Print/Scan the "bad email" table for manual verification. You wouldn't want to delete on the first run in case you had a mistake in your code and deleted valid emails.
Once the bad email table has been verified manually, write a script that deletes from "big email" table where bigemail.emailaddress = bademail.emailaddress.
Really pretty easy to do.