Search code examples
regexautomata

Regular Expression of Language {a b} which contains string of Odd Length and must contain atleast one 'b' in it


I've tried the following solution but it may not cover all the strings

b(aa+ab+ba+bb)* + (aa+ab+ba+bb)*b

here + means OR operation and * means repetition.

Can someone debug the above regex?


Solution

  • RE = (a+b)((a+b)(a+b))*b(a+b)((a+b)(a+b))* + ((a+b)(a+b))*b((a+b)(a+b))*

    I hope it will cover all strings