0
votes

For the following DFA NFA

enter image description here

I produced the RE

(a + b)(ab)*

However, I then realised that my RE doesn't accept the empty string as it only accepts strings beginning with an a or a b, yet the DFA NFA also accepts the empty string as the initial state is an accepting state.

What is a valid RE for this DFA NFA? I would think something along the lines of

Ø + (a + b)(ab).*

but I doubt this syntax is accepted.

EDIT

I have also just realised that the example I have made is an NFA, but that is besides the point of the question.

2

2 Answers

0
votes

(a + b)* would be the answer of what you mentioned in the question title. With an *, it means you can have empty string. a+b means you can choose either a or b. So finally you can choose a or b repeatedly.

0
votes

How about the following expression?

^(|[ab](ab)*)$

This accepts either an empty string, or a sequence of none or more times ab, preceded by an a or b.

But it depends on the exact regular expression dialect if this solves your problem.