Constructing Strings using Regular Expressions
Assuming you have a a set E = {a,b}, and you have a superset E* consisting of all possible combinat开发者_如何学编程ions of a, and b in E. How do you construct an expression for a String that has number of a's divisible by 3?
Try
/^(b*ab*ab*ab*)+$/
Examples:
abbb => N
bbb => N
aaab => Y
ababbbba => Y
aaabba => N
bbbaaaabbbabbbba => Y
=> N
精彩评论