Regular Expressions 101

Community Patterns

1...34567...467

Regex tutorial Case sensitive consonants

4

Regular Expression
PCRE (PHP <7.3)

/
[^ -AEIOU[-ÿ]
/
g

Description

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