Regex and Finite Automata

The cluster focuses on the theoretical equivalence between regular expressions and finite state machines like DFAs and NFAs, contrasted with practical regex engines that support non-regular features such as backreferences and backtracking.

📉 Falling 0.3x Programming Languages
1,306
Comments
20
Years Active
5
Top Authors
#3121
Topic ID

Activity Over Time

2007
2
2008
1
2009
19
2010
46
2011
49
2012
29
2013
59
2014
51
2015
106
2016
98
2017
62
2018
80
2019
125
2020
100
2021
103
2022
89
2023
140
2024
81
2025
65
2026
1

Keywords

psu.edu RE LR0 PCRE HN FWIW NP expression.info PDA i.e regex regular finite regular expressions expression state machine expressions state deterministic state machines

Sample Comments

mesaframe Mar 8, 2020 View on HN

Regex is equivalent to Finite Automata

morby Sep 4, 2023 View on HN

Aren’t regular expressions the abstraction to state machines? They all get converted to a DFA or NFA, no?

schoen Nov 3, 2023 View on HN

Regular expressions (in the original computer science sense) can be matched by finite-state automata!

wallscratch Mar 30, 2022 View on HN

Why? Aren’t all regular expressions equivalent to some finite state machine?

hardwaregeek Feb 27, 2025 View on HN

A strict theoretical regex yes, but a lot of regex implementations in practice are not strict NFA/DFAs and may indeed be turing complete

more_original Sep 13, 2015 View on HN

Perl's regex engine must use something stronger than plain NFAs. The expressive power of NFAs and DFAs is exactly the same. They both recognize the regular languages, which is less than what can be expressed with Perl "regular expressions".

sleavey Jan 1, 2021 View on HN

What are DFAs/NFAs? I didn't see them defined in the article.

microtonal Sep 3, 2013 View on HN

Just wondering: why do you build a regex and not directly a finite state automaton? Sure, you can not have backreferences, but you can use Hopcroft minimization, etc.

burntsushi Apr 16, 2020 View on HN

Not as frequent as you might expect! Most regex engines in common use don't use an automata based implementation, and instead use backtracking. This lets them implement additional non-regular features such as backreferences and recursion.Even automata based regex engines don't usually build up a full DFA, since the size of the DFA may be exponential in the size of the regex. Instead, an NFA similation might be used, or a hybrid NFA/DFA that builds the DFA during match time, but

xigoi Nov 13, 2024 View on HN

Why are they called regular expressions if they can parse non-regular languages?