I have a question about how I can read variable numbers (float), it works very well with Java Script, I made a code long ago I need to pass it to the Arduino. In what I translated it, I came across this code, for those who know it "var1.replace(/[^ 0-9]/g,' ')", this replaces all the numbers that exist in var1 to blank spaces. But I can't find a function that can do estp "/[^0-9]/g" (this detects the numbers from 0 to 9). There is "replace()" on the arduino, but I just need that last thing. Thank you!
this replaces all the numbers that exist in var1 to blank spaces.
you want to replace the digits with spaces ?????
sounds like you really want to remove all the spaces preceding a numeric value.
are you familiar with sscanf()?
Translating literally between computer languages is just as bad as translating literally between human languages. Take a good look at the requirements, at the target language, and start from scratch. The original code might supply only some hints at how you should code it.
hiperdoo:
"var1.replace(/[^ 0-9]/g,' ')", this replaces all the numbers that exist in var1 to blank spaces.
Can you describe (in plain language) the meaning of the quoted instruction with a numerical example?
What I want to do is find all the numbers of a String (without counting the points) to be able to replace them with spaces. I need to do that for my project to work.
Iterate through your character array. If the character is between ASCII '0' and ASCII '9', replace it with ASCII ' '. Go for coffee. You can use the function isdigit(c) to test the characters to see if they are numeric.
However, I assure you that this procedure is not needed to read a float number, if that is what you need to make your project work.
hiperdoo:
for those who know it "var1.replace(/[^ 0-9]/g,' ')", this replaces all the numbers that exist in var1 to blank spaces.
I have somehow my doubts; to my knowledge, it replaces everything that is not a digit or a space by a space.
FYI, there is a regular expression 'library' somewhere for the Arduino. New regular expression library released, you'll have to read through it to see if there were updates.
Where does your float come from? From a piece of text in some form; e.g. Serial Monitor?