Give regular expression for the set of strings over $\{a,b,c\}$ with length AT MOST 3

1.4k Views Asked by At

I would just like to confirm the regular expression which I have is correct.

$(\epsilon+a+b+c)*(\epsilon+a+b+c)*(\epsilon+a+b+c)$

Would this be the correct regexp for a set of strings $\{a,b,c\}$ with length AT MOST 3?

2

There are 2 best solutions below

3
On

Yes, I believe your regular expression is correct. If you're allowed to use the $\ \{n\}\ $ operator, a more compact way of writing it would be $$ \left(\epsilon+a+b+c\right)\{3\} $$

0
On

Your expression is coorect. If $A = \{a,b,c\}$ is the alphabet, you could also write it as $(1 + A)^3$ or as $1 + A + A^2 + A^3$.