I have a .txt file with variables called: X,Y,Z. They are delimited by spaces or new lines. It looks like:
Y-3.165 X-25.221 M8
Z32.054
Z26.57 F500
Y0.0 F1000
Y160.8
X-20.254
What i need is to change positive values of X into negative and reverse (negative to positive). The problem is that variables aren't always single on a line, it may be 2 or 3 of them (like: Y-3.165 X-25.221 M8).
I think the algorythm is :
if(found X) -> go ahead till the next space character or line end, recording the characters between X and space or EOL
when having a string like X-0.94 -> delete "-" otherwise -> add "-" symbol between X and first number after it –
But I am not sure if I am on the right track or even how to do it. Can you guide me?