# Regular expression for the language where every a is surrounded by b's

I had a question on an assignment where we were supposed to write a regular expression for a language where every $a$ in $w$ is immediately preceded and followed by a $b$. My answer was $\epsilon + (b + bab)^*$. The teacher pointed out that my answer makes an $a$ surrounded by at least two $b$s, which isn't correct. I can't for the life of me figure out how to fix it to make it correct. Can anyone help?

• Can you give an example of a word in your language not covered by $(b + bab)^*$? (which is by the way equivalent to $\epsilon + (b + bab)^*$) – Yuval Filmus Nov 11 '13 at 20:00
• I believe babab would not be accepted by that regular expression, but it should be. – Bryan Nov 11 '13 at 22:35

Here is a regular expression for your language: $(b(ab)^*)^*$. It's not hard to check that every $a$ is bordered by $b$s in both directions. The other direction is more complicated and left to you.