programAngel Posted June 18, 2012 Share Posted June 18, 2012 Hi,I had a job interview and they asked me about regular expression, I knew most most of the question. However they asked how can I define regular expression that will accept every string that contain equal number of the letter 'a' and 'b', regardless of the other chars.I mean string like:aaabbb (3 - 'a' , a - 'b')afffhgflhgfladflgkdflbdfdsfdsb (2 - 'a', 2 - 'b')avvvbbdda (2 - 'a', 2 - 'b') I told them I know how to create function that will just count the number of 'a' and 'b' and then equate them.but my question is, can I solve it with regular expression and how? Link to comment Share on other sites More sharing options...
Ingolme Posted June 18, 2012 Share Posted June 18, 2012 I don't believe regular expressions are capable of that. That is not what regular expressions are intended for. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now