Regular Expressions 101

Community Patterns

Regex tutorial Case sensitive consonants


Regular Expression
PCRE (PHP <7.3)

[^ -AEIOU[-ÿ]


With regex you can count the number of matches. Can you make it return the number of uppercase consonants (B,C,D,F,..,X,Y,Z) in a given string? E.g.: it should return 3 with the text ABcDeFO!. Note: Only ASCII. We consider Y to be a consonant! Example: the regex /./g will return 3 when run against the string abc.

Submitted by anonymous - 4 years ago