Why regular expressions with backreferences are not regular expressions? [closed]
Asked Answered
T

0

6

This article say:

A backreference like \1 or \2 matches the string matched by a previous parenthesized expression, and only that string: (cat|dog)\1 matches catcat and dogdog but not catdog nor dogcat. As far as the theoretical term is concerned, regular expressions with backreferences are not regular expressions.

Why? For what reason the \1 became "regular expression" no longer a "regular expression"?

Timbale answered 7/11, 2016 at 0:2 Comment(3)
I'm voting to close this question as off-topic because is it a question about the theory of computation, not programming.Topic
IMHO there are a few million programmers that would disagree with whomever made that statement.Sewellel
Bohemian: It does not really matter whether someone disagrees or not. 'Regular' in this context is a technical concept with a strict definition, and simply calling irregular things regular does not change the meaning of the term. A regular expression can describe regular grammars only. The addition of backreferences allows you to describe certain context-free and context-sensitive grammars.Ascidian

© 2022 - 2024 — McMap. All rights reserved.