Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Converting dot-star regular expression into NFA

I'm converting a given set of regular expressions into a single NFA, but I'm having some issues. How should I convert a regular expression such as "ab.*c" (representing matching an 'a', a 'b', any number of characters, and then a 'c')?

My final goal is to convert the single NFA into a DFA (and I'm using the subset construction algorithm for that).

like image 769
Alexandre Dias Avatar asked Nov 21 '25 11:11

Alexandre Dias


1 Answers

A .* in a regular expression corresponds to a looping state in the NFA for every letter of its alphabet.

That state will also have transition for c to the acceptance state.

It is perfectly ok to have c both in the loop transition and the acceptance transition - that's why it is nondeterministic.

like image 174
Anders Lindahl Avatar answered Nov 24 '25 03:11

Anders Lindahl



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!