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"?

macabeus
  • 4,156
  • 5
  • 37
  • 66
  • I'm voting to close this question as off-topic because is it a question about the theory of computation, not programming. – Raymond Chen Nov 07 '16 at 01:12
  • IMHO there are a few million programmers that would disagree with whomever made that statement. – Bohemian Nov 07 '16 at 01:24
  • 2
    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. – Erik Haliewicz Sep 04 '18 at 22:36

0 Answers0