in reply to RFC: Perl regex to validate arithmetic expressions

You actually can parse an arithmetic expression with a "regular" expression if it uses a stack automata. Just think that a regular language can't even check if there is a correct number of parenthesis if the maximum depth is undefined, as such, strictly speaking that is not so much regular...
  • Comment on Re: RFC: Perl regex to validate arithmetic expressions

Replies are listed 'Best First'.
Re^2: RFC: Perl regex to validate arithmetic expressions
by JavaFan (Canon) on Feb 22, 2011 at 09:58 UTC
    Since 5.10, Perl regular expressions can match anything that's matched by a context-free grammar - and then some (backreferences add even more power). Matching balanced parenthesis is easy in 5.10 and later: /^(\((?1)*\))$/.