I’m building a calculator which can operate on cells in a spreadsheet, and need a regular expression for part of it.
What I need to parse out are the following:
- digits: integers.
- cell names: are named like ‘alpha character’ + ‘digit’ ie. A1, B2…
- operations: +, -, *, /
An example would be something like:
23 A4 * 2 B5 /
Here I would want the groups to be: 23, A4, *, 2, B5, /
It shouldn’t be tough, but the operations throw me off.
The reason for wanting a regex and not just splitting on spaces is for validation. I’m looking for some very specific things, so I thought a regex would be the best thing to use.
From some research, and the comments above, it looks like a regex probably isn’t the best way to do what I wanted.
I’ll have to try splitting, then looping over all the split groups to validate.