Regular Expressions 101

Community Patterns

Match Consonants

-1

Regular Expression
PCRE2 (PHP >=7.3)

/
[b-df-hj-np-tv-z]
/
gm

Description

Use regex to test whether a letter is a consonant or not. Use /[B-DF-HJ-NP-TV-Z]/ for capitals.

Submitted by Matthew Hiebing - 2 years ago