# Is it possible to build any regular expression in a computer language with just 3 basic operators?

Many computer languages have complex regular expressions tools. For example, in Javascript you have global flags, escape characters, whitespace character, assertions, character classes, groups and ranges etc. I'm wondering if using just the 3 basic regular expressions operators as defined in formal languages, that is concatenation, alternation and Kleene star can achieve the same result as any pattern described with more tools as for example in Javascript. Is there a theorem about this?

• Alternation? Why didn't the book or doc you're reading call it disjunction? – JohnnyApplesauce Sep 25 '20 at 17:01
• The features that you list include things that aren't part of the regular expression ("global flags"), are mere syntactic representation ("escape characters"), or are shorthands for alternation ("character classes", "range"). You already have an answer for your question as written, but if you're interested in this subject, you might want to spend some time understanding regular expressions better. – ruakh Sep 25 '20 at 21:27
• @JohnnyApplesauce -- "alternation" is often used in describing regular expressions. I suspect it's more common than "disjunction", but both mean the same thing. – Pete Becker Sep 26 '20 at 15:31

Regular expressions using only concatenation, alternation and Kleene star describe regular languages. In contrast, extended regular expressions available in modern programming languages can describe non-regular languages. For example, (.*)\1 describes the language $$\{ ww : w \in \Sigma^* \}$$, which is not even context-free.