The String
replace()
function allows you to replace all instances of a given character with another character. You can also use replace
to replace substrings of a String with a different substring.There is no circuit for this example, though your board must be connected to your computer via USB and the serial monitor window of the Arduino Software (IDE) should be open.
Caution: If you try to replace a substring that's more than the whole String itself, nothing will be replaced. For example:
1String stringOne = "<html><head><body>";2stringOne.replace("<html><head></head><body></body></html>", "Blah");
In this case, the code will compile, but
stringOne
will remain unchanged, since the replacement substring is more than the String itself.You can find more basic tutorials in the built-in examples section.
You can also explore the language reference, a detailed collection of the Arduino programming language.
Last Revision 2018/03/27 by SM