&gt; Constructing the minimal DFA for a given NFA is PSPACE-hard.<p>This isn&#x27;t really a problem if you incur that cost only once by having the regex compiled when the script is parsed. However, idiomatic JS usually includes regex literals in the closure where it is used - decreasing performance, code reuse and clarity. Why? Probably for the same reasons that regex is being used in the first place.