65.9K
CodeProject is changing. Read more.
Home

Parsing a postfix expression in C#, my naive approach

starIconstarIconstarIcon
emptyStarIcon
starIcon
emptyStarIcon

3.67/5 (5 votes)

Dec 2, 2010

CPOL
viewsIcon

12125

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