0
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:

  1. Do the above statements return valid output (doesn't start and with vowel).

  2. 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]$');         
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • Please clarify your second question since you contradict yourself. You get the same results but you get different results? – D Stanley Feb 01 '16 at 14:58
  • the above questions give same result to each other,below ones give different to one an other –  Feb 01 '16 at 15:02
  • That's where I'm confused - the two sets of queries are exactly the same that I can tell. If there's a subtle difference please highlight it. – D Stanley Feb 01 '16 at 15:07
  • That said I will note that `^[^AEIOU]*[^aeiou]$` and `^[AEIOU].*[aeiou]$` will give different results. The difference is what the middle `*` operator is applied to. – D Stanley Feb 01 '16 at 15:08
  • comment if you mean the first two queries give different answers "with respect to each other". –  Feb 01 '16 at 15:31
  • And I quote am asking the similarity among the first two queries. –  Feb 01 '16 at 15:32

1 Answers1

0

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:

  • Marcos is a match for the first and the second
  • MARCOS is a match for the second and not the first
  • allan is a match for both

2) The second pair presents different output for similar reasons.

You can try it yourself: Regular expressions 101