/* String indexOf() and lastIndexOf() functions Examples of how to evaluate, look for, and replace characters in a String created 27 July 2010 by Tom Igoe http://arduino.cc/en/Tutorial/StringIndexOf This example code is in the public domain. */ void setup() { Serial.begin(9600); Serial.println("\n\nString indexOf() and lastIndexOf() functions:"); } void loop() { // indexOf() returns the position (i.e. index) of a particular character // in a string. For example, if you were parsing HTML tags, you could use it: String stringOne = "
"; int firstClosingBracket = stringOne.indexOf('>'); Serial.println("The index of > in the string " + stringOne + " is " + firstClosingBracket); stringOne = ""; int secondOpeningBracket = firstClosingBracket + 1; int secondClosingBracket = stringOne.indexOf('>', secondOpeningBracket ); Serial.println("The index of the second > in the string " + stringOne + " is " + secondClosingBracket); // you can also use indexOf() to search for Strings: stringOne = ""; int bodyTag = stringOne.indexOf(""); Serial.println("The index of the body tag in the string " + stringOne + " is " + bodyTag); stringOne = "Lorem ipsum dolor sit amet
Ipsem
Quod
"; int lastParagraph = stringOne.lastIndexOf("