String replace Function
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.
- Arduino Board
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:
String stringOne = "<html><head><body>"; String stringTwo = stringOne.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.
String object - Your Reference for String objects
CharacterAnalysis - We use the operators that allow us to recognise the type of character we are dealing with.
StringAdditionOperator - Add Strings together in a variety of ways.
StringAppendOperator - Use the += operator and the concat() method to append things to Strings
StringCaseChanges - Change the case of a String.
StringCharacters - Get/set the value of a specific character in a String.
StringComparisonOperators - Get/set the value of a specific character in a String.
StringConstructors - Initialize String objects.
StringIndexOf - Look for the first/last instance of a character in a String.
StringLength - Get the length of a String.
StringLengthTrim - Get and trim the length of a String.
StringStartsWithEndsWith - Check which characters/substrings a given String starts or ends with.
StringSubstring - Look for "phrases" within a given String.
StringToInt - Allows you to convert a String to an integer number.
Last Revision 2018/03/27 by SM