To reproduce:
create a table with a data type of varchar (50) and name it email
insert into this table the following values:
test1(at)anyemail(dot)com
Execute the following statement:
SELECT CASE WHEN count(substring(email FROM '@.')) > 0 THEN count(substring(email FROM '@.')) ELSE 0 END, email FROM your_schema.your_table GROUP BY email;
Result with be equal to 1 / True. It should be 0 / False.
If you execute the above but replace '@.' with '@a' it will also return 1 / True is correct.
The only time it fails for me is if the @ is immediately followed by a period.
7.3.4 using psql via pgadminIII under cygwin.
Mike