I would like to construct a regular expression of length at least 5 that starts with 'f' and ends with 'y' and who's second symbol is 'u' from the alphabet {a,b,...,z}. My solution to this problem is: $$$$ Let m be a string s.t. $\{m\in\{a,b,...,z\}^* \mid$ m has length that is at least 5, starts with 'f' and ends with 'y' and who's 2nd symbol is 'u'$\}$ Then,$$m=fun^*n^*y$$ Does that seem right?$$$$ Edit: After reading some comments below shouldn't the answer be $$fum^*m^*y$$ since m is any of the letters a through z, but then if m is an empty string we get fuy and it doesn't meet the condition of being of length 5 so is there a way to say that m cannot be empty in fum*m*y, but in such a way that it is in the form of a regular expression? $$$$ Second Edit: After reading up on some examples I would say that the answer would be $$m=fum^+m^+y$$ that is it starts with f followed by u and at least one m followed by at least one more m and ends in y but I'm still unsure if $$m^+$$ could still be an empty string in which case I would have to define a new alphabet that contains no empty string and use that i.e. $$$$ Let $A=\{m^\prime \in \{a,b,...,\} \mid m $ doesn't contain empty string $\}$ and then we get: $$m^\prime=fu m^\prime m^\prime y$$ the only thing is I am not sure if every set has to have an empty string or that I can just construct a new alphabet and use it in my answer.
2026-03-25 12:30:07.1774441807
Regular expression construction.
111 Views Asked by Bumbble Comm https://math.techqa.club/user/bumbble-comm/detail At
1
The answer $fuMM^{+}y$ will match strings you are looking for. The first $m$ picks a single character from the alphabet. The $m^{+}$ picks at least one more character from the alphabet.
Note that I define $M = (a + b + c + d + e + ... + z)$, which is different from how you defined it. This way, $m$ is a single character, not the Kleene closure of the alphabet.
Edit: I might use the syntax $fu[a-z][a-z]^{+}y$.