I have a name column and I need to check whether it starts with letters A to P, or the first 2 letters of the name are AA to AE.
I tried this:
select name
from table
where substring(name,1,1) ~* '^[A-P]'
or substring(name,1,2) ~* '^[AA-AE]';
This didn't work.