#1 India's Top IT Training Institute
×

About Uncodemy

Know more about who we are and what we stand for.

About Us

About Us

Discover our mission to equip individuals with essential IT skills and industry expertise.

Read More →
UnCodeMy Gallery

UnCodeMy Gallery

Explore highlights from our IT training sessions and success stories.

Read More →
Mentors

Mentors

Meet the industry experts who train and guide you through your course.

Read More →
Free Resources

Free Resources

Free tutorials, interview questions, tools and calculators to help you learn.

Explore →
×

Free Resources

Learn, practice and plan your career — bilkul free.

Tutorials

Tutorials

Step-by-step written tutorials to learn any technology at your own pace.

Read More →
Free Counselling

Free Counselling

Book a free video counselling session and pick the right course for you.

Read More →
Online Compiler

Online Compiler

Write, run and test your code online — no setup required.

Read More →
⚡ FREE · STEP BY STEP

Regex to NFA Converter: Thompson's Construction Step by Step

Type a regular expression to build its ε-NFA piece by piece.

  • 🧱 Each sub-expression built
  • 📋 Transition table with ε
  • ▶️ Test a string

How to use the Regular Expression to NFA (Thompson) Converter

  1. 1. Type the expressionUse | for union, * for star, ? for optional and ( ) for grouping. Pick what + means in your book.
  2. 2. Pick a styleMerge states on concatenation (Aho–Ullman) or join the pieces with an ε-move.
  3. 3. Read the NFASee the construction order, the transition table, ε-closure of the start state and a run on your test string.

Thompson's rules

  • Symbol a: new start i, new accept f, move i –a→ f. ε works the same way with an ε-move.
  • Union s | t: new start with ε-moves to both starts, and ε-moves from both accepts to a new accept.
  • Concatenation st: the accept of N(s) becomes the start of N(t).
  • Star s*: new start and accept; ε-moves start → N(s), N(s) accept → N(s) start, N(s) accept → accept and start → accept.

The result has one start state with no incoming moves and one accept state with no outgoing moves, and at most twice as many states as symbols and operators.

Worked example: (a|b)*abb

This is Aho–Ullman's example. The union a | b uses states 1 to 6, the star adds 0 and 7, and abb adds 8, 9 and 10, for 11 states with start 0 and accept 10.

The moves are 0 → 1, 7; 1 → 2, 4; 2 –a→ 3; 4 –b→ 5; 3, 5 → 6; 6 → 1, 7; 7 –a→ 8; 8 –b→ 9; 9 –b→ 10 (unlabelled moves are ε). ε-closure(0) = {0, 1, 2, 4, 7}, which is the start state of the DFA from the subset construction. With the ε-join style, each of the 3 joins adds a state, giving 14.

Frequently asked questions

Does + mean union or one-or-more?

In many theory of computation books a + b means union. In programming, a+ means one or more. Pick the meaning your course uses.

How do I get a DFA from this NFA?

Use subset construction: start from ε-closure of the start state and follow each symbol. Our NFA to DFA converter does this from a transition table.

Why are there so many ε-moves?

Thompson's construction is simple and always correct, but it uses ε-moves to glue pieces together. Subset construction and minimisation remove them later.

More free tools

See all free tools