I'm attempting this question and I'm not sure if I'm on the right track here's what I got.
(a+b)* a (a+b)* b
would this be the regular expression for a set of strings over {a,b} that contain the substring a and substring b?
Thanks!
I'm attempting this question and I'm not sure if I'm on the right track here's what I got.
(a+b)* a (a+b)* b
would this be the regular expression for a set of strings over {a,b} that contain the substring a and substring b?
Thanks!
Let $A$ be the alphabet. Then the set of words containing the letters $a$ and $b$ can be written as $A^*aA^*bA^* + A^*bA^*aA^*$. This works for any alphabet containing $a$ and $b$.
However, the case $A = \{a,b\}$ is more tricky since in this case the regular expression $A^*(ab + ba)A^*$ would also work, since any word containing $a$ and $b$ contains either the factor $ab$ or the factor $ba$. This would not work with $A = \{a,b,c\}$ since $acb$ contains $a$ and $b$.