Last Updated on Sep 30, 2016
This is 2nd Part of Regular expression in theory of computation solved examples. You can also read Regular expression in theory of computation solved examples Part – 1.
4. Construct a regular expression for the set of all strings over (A, . . . ., Z, a, . . . . , z) that contain the word “main”.
Solution:
We have the input alphabets ∑ = {A, . . . ., Z, a, . . . . , z}
Here, the resultant regular expression will denote the set of all string over the given ∑ which contains the word “main”.
In the first step, let us assume that
<letter> = {A, . . . , Z, a, . . . . . z}
Thus, the regular expression for the set of all strings over the given ∑ can be written as-
<letter>*
Thus, the required resultant regular expression which contains the word “main” can be written as-
<letter>* main <letter>*









It can only handle consecutive a’s! If we have a string like
aabcbca or abcaba
it can not handle them!