2
Finally figured out a regex trick to clean up messy email lists in Mailchimp
After hours of manually fixing duplicate entries and weird characters from a CSV export, I used a simple find-and-replace regex to strip everything but valid email formats in one go, and now I'm wondering why I didn't learn this sooner has anyone else got a go to regex for list cleaning?
3 comments
Log in to join the discussion
Log In3 Comments
leo_fisher16d ago
Wait, doesn't regex strip everything except valid emails risk eating legit addresses that have plus signs or dots in them? A lot of people use stuff like name+shop@gmail.com for filtering and a sloppy regex would trash those. I usually go with something that checks for the @ and a proper domain extension like .com or .org rather than trying to match every valid format. Also watch out for spaces inside quotes or line breaks that look weird but are actually fine in real emails.
0
alicehernandez15d ago
Ran into this exact mess last year when I was cleaning up a mailing list. I had a regex that was too strict and it trashed all my name+filter@gmail.com entries. What finally worked for me was keeping it simple: just check for an @ symbol and make sure there's a dot somewhere after it with at least two letters. I also added a check for spaces in weird places because I had a few addresses with "John Doe"@company.com that were totally valid but looked sketchy. Your mileage may vary, but that basic approach caught 99% of what I needed without losing the legit plus sign addresses.
6
grace_campbell15d ago
Funny, I actually go the other way on this. I'd rather lose a few plus sign addresses than let fake emails slip through, because cleanup after a spam bot gets your list is way more work. If someone's using name+filter@gmail.com, they can just use the base email for my list and still filter on their end. Keep it simple or don't bother I say.
-1