select distinct first_name
from EMPLOYEES
where regexp_like(first_name,'^[^AEIOU]*[^aeiou]$');
select distinct first_name
from EMPLOYEES
where regexp_like(first_name,'^[^AEIOU].*[^aeiou]$');
I am trying to find Employee's first name's that doesn't start with and end with a vowel. I came up with above queries. Now I have two questions:
Do the above statements return valid output (doesn't start and with vowel).
Do the above statements return same result always (I get same result when I tried).
But when I tried the below two queries they gave different outputs with respect to each other
select distinct first_name
from EMPLOYEES
where regexp_like(first_name,'^[AEIOU]*[aeiou]$');
select distinct first_name
from EMPLOYEES
where regexp_like(first_name,'^[AEIOU].*[aeiou]$');
1) The two first queries don't give you valid ouput. They match names that start with lowercase vowels or end with uppercase vowels. And they don't give always the same result:
2) The second pair presents different output for similar reasons.
You can try it yourself: Regular expressions 101