[Math] Describe as a regular expression the set of strings over {a,b,c} that contain the substrings aa,bb,cc

formal-languagesregular expressions

What would be an appropriate regular expression for this set of strings listed in my title? i have this so far:

(aa,bb,cc) is a subset of all the strings listed (a,b,c) (it corresponds to the strings over the alphabet (a,b,c))

i was wondering could somebody tell me the correct regular expression for this or tell me if i am on the right track.

Thanks

Best Answer

The regular expression you are looking for is $$(a+b+c)^*aa(a+b+c)^*bb(a+b+c)^*cc(a+b+c)^*$$

Using this regular expression you can form any word $w$ over the alphabet $\{a,b,c\}$ that contains the substring $aa$, $bb$, $cc$.