I just have a question about Regex…. I really have no idea so any kind of help is appreciated.
The question is: Define a regex that characterises the language consisting of all strings of a’s and b’s in which the 2nd and 2nd-Last characters are ‘b’.
Any ideas on how to start the question?
Thanks very much
To solve this you need to:
aorb:^(a|b),bas the second character `^(a|b)bas,bs or both:^(a|b)b[a-b]*b:^(a|b)[a-b]*baorb:^(a|b)b[a-b]*b(a|b)$/^(a|b)b[a-b]*b(a|b)$/.test(string)A proof of concept using jQuery and JavaScript:
JS Fiddle demo.
References: