'Regular expression for words not starting or ending with vowels?

I used this regex: ^[aeiou](\w|\s)*[aeiou]$ for words starting and ending with vowels and it works fine.

But when I use this regex: ^[^aeiou](\w|\s)*[^aeiou]$ for words not starting and ending with vowels, it doesn't work. Can you tell me what is wrong in my 2nd regex?

Words are like:
South Britain
Rives Junction
Larkspur
Southport
Compton
Linden
Sedgwick
Humeston
Siler
Panther Burn



Solution 1:[1]

select distinct(city) from station
  WHERE regexp_like(city, '^[^aeiou](\w|\s)*$', 'i')
    OR regexp_like(city, '^(\w|\s)*[^aeiou]$', 'i');

The question is asking "ends with OR starts with" you can do it in the regex, but I did it as an OR in the WHERE clause

Solution 2:[2]

If I understand the desired logic and if you happen to want a single regular expression, I would use something like !/(^[aeiou](\w|\s)*)|((\w|\s)*[aeiou]$)/i. This, of course, is not the most readable format, but should grab only those words that start AND end with non-vowels.

Solution 3:[3]

Late to the game but if it’s MySQL this is what works for me:

SELECT DISTINCT CITY FROM STATION 
WHERE NOT REGEXP_LIKE(CITY,'[aeiou]$','i') 
OR NOT REGEXP_LIKE(CITY, '^[aeiou]','i');

Solution 4:[4]

Simple and readable solution

SELECT DISTINCT city
FROM station
WHERE city NOT REGEXP '^[aeiou]' AND city NOT REGEXP '[aeiou]$'

Solution 5:[5]

Below is the simplest MS SQL Server command that you can come up with -

SELECT DISTINCT CITY
FROM STATION
WHERE CITY LIKE '[^aeiouAEIOU]%' OR CITY LIKE '%[^aeiouAEIOU]';

it can not get simpler than this.

Solution 6:[6]

In MYSQL I used:

Select distinct City from STATION where City RLike "^[^aeiou].*|[^aeiou]$"

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 bradlis7
Solution 2 Mutagon
Solution 3
Solution 4
Solution 5 samar taj Shaikh
Solution 6 Dhananjay kumar Singh