in reply to Re^2: check for square-number with a regex
in thread check for square-number with a regex
As I pointed out, a classical context-free language that isn't a regular expression is anbn. You cannot match that with 5.8 regular expressions (assuming no jumping back to the interpreter using (?{}) or (??{})), proving that backreferences aren't enough. But in 5.10, you can write /^(a(?1)b)$/, which doesn't use backreferences. It does use recursion, but recursion is the difference between an FA and a PDA.
Now, I think that due to backreferences, Perl regular expressions are more powerful than context-free grammars, but I cannot think of a language that is matched by a Perl regular expression, and not by a context-free grammar. And I don't think Perl regular expressions are as powerful as context sensitive grammars (which requires a TM). For instance, I don't think there's a Perl regular expression to match anbncn.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: check for square-number with a regex
by spx2 (Deacon) on Oct 24, 2009 at 09:56 UTC | |
by JavaFan (Canon) on Oct 24, 2009 at 11:54 UTC |