I was wondering if there was a method that can be used to generate a Regular Expression for a language. Take the Language $L$ as an example where:

$L= \{w \in \{0, 1\}^{\ast} \mid \text{length of } w \text{ is a multiple of } 2 \text{ or } 3\}.$

Can you show the step by step method to make the RE for this language? Cheers

  • $\begingroup$ In general? No, because that would imply you could algorithmically decide whether a given language is regular (impossible). Of course, there are certain methods, e.g. build an NFA and convert it. (Community votes, please: duplicate?) $\endgroup$
    – Raphael
    Jan 16 '16 at 15:33
  • 2
    $\begingroup$ Anyway, what have you tried and where did you get stuck? $\endgroup$
    – Raphael
    Jan 16 '16 at 15:34

Hint: Let's denote $w_{\text{two}}$ words with length that is a multiple of $2$

and $w_{\text{three}}$ words with length that is a multiple of $3$

So think about:



Not the answer you're looking for? Browse other questions tagged or ask your own question.