Hello folks, I have a fairly simple problem here. I have a robot project and I'll simplify a bit but basically the communication syntax between robot and computer looks a bit like this "<0.1234JX>". I realize now that its not the best way but it worked well when the robot was in its infant stages, and rather than rewrite every location where they communicate, i really just need to pull out the 0.1234 from that string. the < and > will always be at the beginning and end. Im looking at numbers in about the range of 1000 down to 0.0001, and including negatives. The Arduino on the robot can parse this out easily with the atof(str) function, but i can't seem to find a processing equivalent. I dont want to use a for() loop for parsing, if I can avoid it. I have tried using Float.parseFloat(trim(clientindata)); and similar, but I get either a NaN or a communication error. Any ideas? Greatly appreciated!
Ah excellent these will definitely help! I forgot to mention that JX could be many different combinations of letters, but it looks like
d.replaceAll("[^\\d.-]", ""); will take care of that! Thanks folks!
Leave a comment on xenophage's reply
Change topic type
Link this topic
Provide the permalink of a topic that is related to this topic