Solange auf dem Stack noch Platz für eine Arbeitskopie ist, würde dies funktionieren.
String currentLine = "%2216%22,%20%2217%22";
void removestr(String& aString, const char* str2Remove) {
size_t len = aString.length();
if (len == 0) return ;
size_t len2Remove = strlen(str2Remove);
if (len2Remove == 0) return;
char str[len + 1];
memcpy(str, aString.c_str(), len + 1);
char *readFrom = str;
char *foundAt;
while ((foundAt = strstr(readFrom, str2Remove)) != NULL) {
memmove(foundAt, foundAt + len2Remove, (readFrom + len) - (foundAt + len2Remove) + 1); // move the '\0' at the same time
readFrom = foundAt;
len -= len2Remove;
}
aString = str;
}
void setup()
{
Serial.begin(115200);
Serial.println(currentLine);
removestr(currentLine, "%22");
Serial.println(currentLine);
removestr(currentLine, "%20");
Serial.println(currentLine);
Serial.println("Das Ergebnis sollte 16,17 sein");
}
void loop() {}