Click here to Skip to main content
15,884,298 members
Articles / Programming Languages / C#
Alternative
Tip/Trick

Parsing a postfix expression in C#, my naive approach

Rate me:
Please Sign up or sign in to vote.
3.67/5 (5 votes)
19 Dec 2010CPOL 11.3K   1   3
Regex combined = new Regex(@"\G(\s+(?[+-*/])|\s*(?-?[0-9]+))", RegexOptions.ExplicitCapture);This line has an error:parsing "\G(\s+(?[+-*/])|\s*(?-?[0-9]+))" - [x-y] range in reverse order.
Regex combined = 
                new Regex(@"\G(\s+(?<op>[+-*/])|\s*(?<value>-?[0-9]+))", RegexOptions.ExplicitCapture);</op>


This line has an error:
parsing "\G(\s+(?<op>[+-*/])|\s*(?<value>-?[0-9]+))" - [x-y] range in reverse order.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralI expect it is the - in the first group.. changing it to [-+... Pin
Morten Nilsen21-Dec-10 0:32
Morten Nilsen21-Dec-10 0:32 
GeneralReason for my vote of 1 This is a valid comment, but doesn't... Pin
Darchangel6-Dec-10 2:53
Darchangel6-Dec-10 2:53 
GeneralReason for my vote of 1 This is really a comment, not an Alt... Pin
Toli Cuturicu4-Dec-10 7:42
Toli Cuturicu4-Dec-10 7:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.