Nov 11, 2014

Why aren't Perl's patterns regular expressions?

Because Perl patterns have backreferences.
A regular expression by definition must be able to determine the next state in the finite automaton without requiring any extra memory to keep around previous state. A pattern /([ab]+)c\1/ requires the state machine to remember old states, and thus disqualifies such patterns as being regular expressions in the classic sense of the term.

1 comments:

  1. Learn idiomatic expressions with comprehensive meaning, examples and origin details in easy to find classification system including search, alphabetical order and more.

    ReplyDelete