tags:

views:

276

answers:

2

To outline: I have a parser that grabs Cell references using the following regex

"$"?{letter}{1,2}"$"?{digit}{1,3}

I cant seem to find an elegant way to split the resulting char* into its row, and column components.

ex. split a1 into a and 1 or split $aa$4 into fixed_col a fixed row 4

Any help is appreciated.

+1  A: 

Are you using a regex library? If so does it support accessing grouped parts of the regex, something like:

("$"?)({letter})({1,2})("$"?)({digit}{1,3})

(This article shows the technique using the .NET regex library)

If that isn't an option, then building a simple state machine would work well, and be easy to maintain and test.

Rob Walker
A: 

unfortunately no regex library :(

State machine looks like my best option. Thanks Rob.

Holograham