Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: RFC: Perl regex to validate arithmetic expressions

by mellon85 (Monk)
on Feb 21, 2011 at 18:53 UTC ( #889463=note: print w/replies, xml ) Need Help??


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)*\))$/.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://889463]
help
Chatterbox?
[1nickt]: hippo lately I can tell just by the fact that Anonymous posts a reply after some hours that it is more than likely That Monk.
[virtualsue]: weird. my p6 simple web spider fails to extract anchor tags from perlmonks.org
[holli]: Nice. Turns out I don't have to remove Sweet home Alabama from my playlist ;)
[Corion]: virtualsue: We have some links with a newline between <a and the attributes, maybe your extractor fails to handle that?
[virtualsue]: It's not getting any at all, which seems quite broken

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (6)
As of 2017-12-13 11:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What programming language do you hate the most?




















    Results (360 votes). Check out past polls.

    Notices?