/[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.
/[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.
16 char regex
(?![AEIOU])[A-Z]
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
You can get it a little bit shorter by using a \P{Lu}
class:
[^\P{Lu}AEIOU]
[I'm not restricting this to Javascript because regex101 is primarily PCRE flavour]
The above has 14 characters. Since the puzzle also adds in characters from the word boundaries and flags, this adds 3 more characters for //g
, hence total 17 characters.
In .NET, you can do it shorter:
[B-Z-[EIOU]]
(12 chars long)
For javascript:
(?![EIOU])[B-Z]
15 chars excluding delimiters and flag.
My regex is 17 characters in length! I am still one shorter!
(?=[A-Z])[^AEIOU]
Using lookahead it is first checking the next character is in between A-Z
or not. Then its checking for a Non-Vowel
character.