Regular expression .Find it

54 Views Asked by At

Construct a regular expression that defines the language of all words that contain either the aa-substring or the bb-substring but NOT BOTH the aa-substring and the bb-substring in the same word.Please tell me if my answer is correct and if so is there a way to shorten it .Alphabet is{a,b} .So i assumed its a and b . My answer is ((a+b)(aa*+bb*)(a+b))+(aa*+bb*)(a+b)+(a+b)(aa*+bb*)