3 ms·
# get email addresses grep -EiEio '\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b' # censor email addresses sed -r 's/(<)[[:alpha:][:digit:]\._%\+-]+@[
by LinuxBender 11y ago
# get email addresses
grep -EiEio '\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b'
# censor email addresses
sed -r 's/(<)[[:alpha:][:digit:]\._%\+-]+@[[:alpha:][:digit:]\.-]+\.[[:alpha:]]{2,4}(>)/\1--removed--\2/g'
If email doesn't meet those, I drop them on the floor. Then again, I drop email on the floor for lesser reasons.
- lstamour 11y agoSo any new gtld longer than four characters would be dropped on the floor? E.g. .software? If you're trying to censor email addresses from a file, that doesn't work that well. :)
- LinuxBender 11y agoYes. Actually for the longest time I rejected the connection with "Your name is too awesome!"
- Symbiote 11y agoSo you're blocking email from your local .museum, from anyone who has an Irish name like O'Connor, all international TLDs, and most newer TLDs.
- LinuxBender 11y agoYes.
- mcv 11y agoThis would not allow email addresses with an = in them, which I've had. The point of my overly tolerant regex is exactly that: any more restrictive validation is going to drop some perfectly legal email addresses. Sending an email is the only way to be sure.