Hi.
I use regexp for arduino nano.
But, code not runing. Please help me.
I defined a string named meta.
In string: "seta-1.5 nema oma hama"
I want to save the value after the seta (+ -) as float. but I could not. can you help me. code:
String meta;
if (meta.indexOf(seta) > -1) {
MatchState ms;
ms.Target(meta.c_str());
char result = ms.Match("seta[+-]?%d*%.%d+)(?![-+0-9%.]);
if (result == REGEXP_MATCHED)
{
char buf(100);
Float k = atof(ms.GetCapture(buf, 0));
Serial.println(k,1);
}
Read this: Read this before posting a programming question .... As the title says, you should have read it before posting. Read it all, but pay particular attention to Item #6. Post your code correctly using Code Tags.
Also, before posting again, auto-format your code (ctrl-t in the Arduino IDE) so that you have proper indenting.
lesept:
Search for the position of 'seta' in your string add 4 and take the right part of the string beginning at that position. Then do the tofloat thing
You're welcome.
BTW you should know that using Strings may cause memory problems if your code runs for a "long" time. I helped you in this way because you had already begun to work with Strings, but it may be a good idea to swap to c-strings, aka arrays of char