title: PostgreSQL regex to validate email addresses
body: <pre><code>CREATE OR REPLACE FUNCTION addUploader(INTEGER, TEXT, TEXT) RETURNS TEXT AS $$
  
  DECLARE
  
    u_id ALIAS FOR $1 ;
    username ALIAS FOR $2;
    email ALIAS FOR $3; 
  
  BEGIN 
  
    IF email NOT LIKE '^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+[.][A-Za-z]+$' THEN
  
      RAISE EXCEPTION 'Wrong E-mail format %', email
          USING HINT = 'Please check your E-mail format.';
  
    END IF ; 
  
    INSERT INTO uploader VALUES(u_id,username,email);
  
    IF NOT FOUND THEN
      RETURN 'Error';
    END IF;
    RETURN 'Successfully added' ; 
  
  EXCEPTION WHEN unique_violation THEN
    RAISE NOTICE 'This ID already exists. Specify another one.' ; 
    RETURN 'Error' ; 
  
  END ; $$ LANGUAGE 'plpgsql' ; 
  
  SELECT addUploader(25,'test','steven@gmail.com');
  </code></pre>
  
  <p>This regex does not accept a correct email address. It should accept steven@gmail.com.It is also rejecting any other string. </p>
  
  <p>stevengmailcom - rejected</p>
  
  <p>Everything is being rejected.</p>
  
  <p>What am i doing wrong? </p>