in reply to S/// for Switch-case-default to if-if else-else conversion

Recursive parsing is always troublesome with regular expressions. Since your code looks well-formatted, I would use a line-based approach which will make it a lot easier to "whip-it-up" (i.e. debug, develop, modify.)

btw, what language is this for? - I have a feeling the language you are parsing is not perl. If it is, just use perl 5.10 which has given...when.

Replies are listed 'Best First'.
Re^2: S/// for Switch-case-default to if-if else-else conversion
by DanielNeedles (Novice) on Jul 07, 2008 at 03:33 UTC
    It is Netcool rules file which is a proprietory glorified massive if then else statement with variable, field, and property assignments.
      Then you should show us what you want to convert it to. There are a lot of implementation details to consider. For instance, will you need to create an intermediate variable for the switch value, and if so, how do you do that? Also, how do you test for equality in Netcool, and is there a difference between string equality and number equality?