Laurent Crivello
Laurent Crivello

Reputation: 3931

Regular expression matching specific single characters or specific combination

I am looking for a regular expression matching specific single characters or specific combination of them like:
BCDFGHJKLPQRSTVWXZ for the singles
PR FR TR GR CR PH CH for the doubles

How can I put this in a regular expression ? Thanks.

Upvotes: 0

Views: 44

Answers (1)

vks
vks

Reputation: 67988

[BCDFGHJKLPQRSTVWXZ]

for singles

(?:\bPR\b|\bFR\b|\bTR\b|\bGR\b|\bCR\b|\bPH\b|\bCH\b)

for the doubles

You can do this using character class and alternation operator or OR operator.

EDIT:For both in single expression.

[BCDFGHJKLPQRSTVWXZ]|(?:\bPR\b|\bFR\b|\bTR\b|\bGR\b|\bCR\b|\bPH\b|\bCH\b)

Upvotes: 2

Related Questions