Skip to content

Instantly share code, notes, and snippets.

@chanmix51
Created March 24, 2011 21:47
Show Gist options
  • Save chanmix51/885966 to your computer and use it in GitHub Desktop.
Save chanmix51/885966 to your computer and use it in GitHub Desktop.
Returns true or false whatever the string given is a valid email or not
CREATE OR REPLACE FUNCTION is_email(email VARCHAR) RETURNS BOOLEAN AS $$
BEGIN
RETURN email ~* '^([^@s]+)@((?:[-a-z0-9]+.)+[a-z]{2,})$';
END;
$$ LANGUAGE plpgsql
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment