Click here to Skip to main content
15,125,459 members
Articles / Programming Languages / C#
Posted 2 Dec 2010

Tagged as


1 bookmarked

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
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.


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


About the Author

United States United States
No Biography provided

Comments and Discussions

GeneralI expect it is the - in the first group.. changing it to [-+... Pin
Morten Nilsen21-Dec-10 1:32
MemberMorten Nilsen21-Dec-10 1:32 
GeneralReason for my vote of 1 This is a valid comment, but doesn't... Pin
Darchangel6-Dec-10 3:53
MemberDarchangel6-Dec-10 3:53 
GeneralReason for my vote of 1 This is really a comment, not an Alt... Pin
Toli Cuturicu4-Dec-10 8:42
MemberToli Cuturicu4-Dec-10 8:42 
Reason for my vote of 1
This is really a comment, not an Alternate, isn't it?

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.