Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is this the shortest javascript regex to find all uppercase consonants?

/[B-DF-HJ-NP-TV-Z]/g

This is 20 total characters. http://regex101.com/quiz/# quiz #3 says that the shortest solution is 16 characters, but I'm not sure if that is for the JavaScript flavor of regexes.

like image 290
Keith Grout Avatar asked Mar 28 '14 23:03

Keith Grout


2 Answers

16 char regex

(?![AEIOU])[A-Z]

like image 126
Crayon Violent Avatar answered Sep 28 '22 19:09

Crayon Violent


this is Only ASCII, so this will the shortest regex, use Negated Character Classes, please see Negated Character Classes

[^ -AEIOU[-ÿ], 13 characters

/[^ -AEIOU[-ÿ]/g, with flag, 16 characters

like image 41
lautumn Avatar answered Sep 28 '22 17:09

lautumn