- Max Length of the String is 6.
- The string should contain at most 2 digits
- The string should contain at most 4 alphabets
So the following examples should match
abcd22
a1cd3d
11acde
a1c
1ad
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
What you want isn’t really possible in regular expressions because regular expressions can’t count, which would be required here. In fact, regular expressions seem to be able to count characters in direct sequence, e.g. in this case:
… but that’s actually not counting, because it’s just a shortcut for this expression:
i.e. 2
x’s, followed by an optional third one.Your expression, on the other hand, would have to keep track of two different counters over the whole automaton which represents the expression. That’s simply not possible in classical regular expressions (and still very hard using more modern incarnations of regular expressions which use pushdown automata to save states).