I have the following Arduino sketch using regex but the matches and searches fail. I just do not know why,
This is a very trivial example but I wish to search in complex xml strings. I do not wish to use find and substr. It is so much neater with regex. Any help is very much appreciated
#include <Arduino.h>
#include
#include
void setup() {
Serial.begin(115200);
Serial.println();
std::string rl = "HTTP kjjkjk 200 kl";
std::regex rex("^HTTP");
std::smatch bmatch;
if (std::regex_search(rl, bmatch, rex)) {
Serial.print("found match1 "); Serial.println(bmatch.size());
Serial.println(bmatch.str().c_str());
}
Serial.print("Searched for HTTP. Search = "); Serial.println( std::regex_search(rl, rex));
std::smatch cmatch;
std::regex rexkk("^.(200).");
if (std::regex_match(rl, cmatch, rexkk)) {
Serial.print("found match2 "); Serial.println(cmatch.size());
Serial.println(cmatch.str().c_str());
}
Serial.print("Matched for "^.(200)." Match = "); Serial.println( std::regex_match(rl, rexkk));
}
void loop() {
// put your main code here, to run repeatedly:
}
Output:
Searched for HTTP. Search = 0
Matched for "^.(200)." Match = 0