initial commit

This commit is contained in:
lsdlsd88
2024-04-25 17:22:13 +02:00
parent 683b846d60
commit b5204b2a68
2737 changed files with 1534650 additions and 0 deletions
@@ -0,0 +1,61 @@
#include <Regexp.h>
// called for every match
void replace_callback (const char * match, // what we found
const unsigned int length, // how long it was
const char * & replacement, // put replacement here
unsigned int & replacement_length, // put replacement length here
const MatchState & ms) // for looking up captures
{
// show matching text
Serial.print("Match = ");
Serial.write((byte *) match, length);
Serial.println ();
replacement = "Nick";
replacement_length = 4;
} // end of replace_callback
void setup ()
{
Serial.begin (115200);
Serial.println ();
unsigned long count;
// what we are searching (the target)
char buf [100] = "The quick brown fox jumps over the lazy wolf";
// match state object
MatchState ms (buf);
// original buffer
Serial.println (buf);
// search for three letters
count = ms.GlobalReplace ("%a+", replace_callback);
// show results
Serial.print ("Converted string: ");
Serial.println (buf);
Serial.print ("Found ");
Serial.print (count); // 9 in this case
Serial.println (" matches.");
// copy in new target
strcpy (buf, "But does it get goat's blood out?");
ms.Target (buf); // recompute length
// replace vowels with *
count = ms.GlobalReplace ("[aeiou]", "*");
// show results
Serial.print ("Converted string: ");
Serial.println (buf);
Serial.print ("Found ");
Serial.print (count); // 13 in this case
Serial.println (" matches.");
} // end of setup
void loop () {}