Skip to content

Instantly share code, notes, and snippets.

@jeff

jeff/email.sql Secret

Created December 16, 2013 20:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeff/ed8f9acd3e501b52875c to your computer and use it in GitHub Desktop.
Save jeff/ed8f9acd3e501b52875c to your computer and use it in GitHub Desktop.
-- select syntactically-improbable email addresses (and a redacted form)
-- be tolerant of leading/trailing spaces as that seems common, and is
-- probably safe to remove in a batch update
SELECT email, regexp_replace(email, '[a-zA-Z0-9]', 'Z', 'g') as redacted
FROM actor.usr
WHERE home_ou IN (SELECT id FROM actor.org_unit_descendants(1))
AND email !~ '^ *[a-zA-Z0-9\._+-]+@([a-zA-Z0-9-]+\.)+[a-zA-Z]{2,} *$'
AND email <> ''
ORDER BY reverse(lower(email));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment