Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
75
rated 0 times [  81] [ 6]  / answers: 1 / hits: 22443  / 12 Years ago, sat, november 24, 2012, 12:00:00

How can I match letters a,b,c once in any combination and varying length like this:



The expression should match these cases:



abc
bc
a
b
bca


but should not match these ones:



abz
aab
cc
x

More From » java

 Answers
1

Use regex pattern


b(?!w*(w)w*1)[abc]+b

You can use this pattern with any set and size, just replace [abc] with desired set...




Example:


enter


(above output is from myregextester)


[#81820] Friday, November 23, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
deonkalvinw

Total Points: 409
Total Questions: 96
Total Answers: 89

Location: Saint Pierre and Miquelon
Member since Sun, Nov 27, 2022
2 Years ago
deonkalvinw questions
Sun, Feb 6, 22, 00:00, 2 Years ago
Tue, Dec 28, 21, 00:00, 2 Years ago
Sun, Aug 22, 21, 00:00, 3 Years ago
Sun, Mar 7, 21, 00:00, 3 Years ago
;