How can I match letters a,b,c once in any combination and varying length like this:
The expression should match these cases:
JavaScript
x
abc
bc
a
b
bca
but should not match these ones:
JavaScript
abz
aab
cc
x
Advertisement
Answer
Use regex pattern
JavaScript
b(?!w*(w)w*1)[abc]+b
You can use this pattern with any set and size, just replace [abc]
with desired set…
(above output is from myregextester)