I'm trying to extract data from a line of gcode which can look like ANY of the following:
G01 X10. Y20. Z3.0 F15.
G00X.500Y-10.
G01 Y10.X20.150
Now I already created my regular expression that matches this perfectly with groups:
(G|M|X|Y|Z|I|J|K|F)(?<val>-?\d*\.?\d+\.?)
and that seems to be working great. I get three groups of data out for each result, example:
G01 X10. Y20. Z3.0 F15.
G01 | G | 01
X10. | X | 10.
Y20. | Y | 20.
Z3.0 | Z | 3.0
F15. | F | 15.
What I'd like to do is be able to check which values are in the input string so I can extract the data and make positional commands. Take the above example, I'd like to extract just the X, Y, and Z values so I can create a Vector of them. This is easy to do when I have all 3 values, but how can I check if a value exists in the first group if the input string is G01 X10. Y5.0
?