Loading...

Tutorial.StringSubstring History

Hide minor edits - Show changes to markup

May 02, 2012, at 09:54 AM by Scott Fitzgerald -
Changed line 66 from:

(:source http://github.com/arduino/Arduino/raw/master/build/shared/examples/8.Strings/StringSubstring/StringSubstring.ino lang=arduino tabwidth=4:)

to:

(:source http://github.com/arduino/Arduino/raw/master/build/shared/examples/08.Strings/StringSubstring/StringSubstring.ino lang=arduino tabwidth=4:)

November 15, 2011, at 10:22 PM by Scott Fitzgerald -
Changed line 66 from:

(:source http://github.com/arduino/Arduino/raw/master/build/shared/examples/8.Strings/StringSubstring/StringSubstring.pde lang=arduino tabwidth=4:)

to:

(:source http://github.com/arduino/Arduino/raw/master/build/shared/examples/8.Strings/StringSubstring/StringSubstring.ino lang=arduino tabwidth=4:)

October 13, 2010, at 02:41 PM by Tom Igoe -
Changed lines 57-58 from:

(:sourceend:)(:divend:)

to:

(:sourceend:) (:divend:)

September 19, 2010, at 05:58 PM by Christian Cerrito -
Changed line 7 from:
div class=BOM
)
to:

(:div class=BOM :)

Added lines 82-84:

September 19, 2010, at 05:58 PM by Christian Cerrito -
Changed lines 5-7 from:

The String function substring() is closely related to charAt(), startsWith() and endsWith(). It allows you to look for an instance of a particular substring within a given String.

(:div class=BOM :)

to:

The String function substring() is closely related to charAt(), startsWith() and endsWith(). It allows you to look for an instance of a particular substring within a given String.

div class=BOM
)
Changed line 9 from:

No external hardware is required.

to:
  • Arduino Board
Added lines 12-22:

Circuit

(:div class=circuit :) There is no circuit for this example, though your Arduino must be connected to your computer via USB.

image developed using Fritzing. For more circuit examples, see the Fritzing project page

(:divend:)

Code

Deleted lines 62-69:

Circuit

(:div class=circuit :) There is no circuit for this example. (:divend:)

Code

September 16, 2010, at 05:06 PM by Tom Igoe -
Changed line 15 from:

[@

to:

(:source lang=arduino tabwidth=4:)

Changed lines 22-23 from:

@]

to:

(:sourceend:)

Changed line 25 from:

[@

to:

(:source lang=arduino tabwidth=4:)

Changed lines 32-33 from:

@]

to:

(:sourceend:)

Changed line 39 from:

[@

to:

(:source lang=arduino tabwidth=4:)

Changed lines 46-48 from:

@] (:divend:)

to:

(:sourceend:)(:divend:)

Changed line 62 from:
 (:source http://github.com/arduino/Arduino/raw/master/build/shared/examples/8.Strings/StringSubstring/StringSubstring.pde lang=arduino  tabwidth=4:)
to:

(:source http://github.com/arduino/Arduino/raw/master/build/shared/examples/8.Strings/StringSubstring/StringSubstring.pde lang=arduino tabwidth=4:)

August 01, 2010, at 12:02 PM by Tom Igoe -
Changed lines 5-6 from:

The String function substring() is closely related to charAt()@, startsWith() and endsWith()@@. It allows you to look for an instance of a particular substring within a given String.

to:

The String function substring() is closely related to charAt(), startsWith() and endsWith(). It allows you to look for an instance of a particular substring within a given String.

August 01, 2010, at 12:01 PM by Tom Igoe -
Added lines 1-81:

Examples > Strings

String substring Function

The String function substring() is closely related to charAt()@, startsWith() and endsWith()@@. It allows you to look for an instance of a particular substring within a given String.

(:div class=BOM :)

Hardware Required

No external hardware is required. (:divend:)

substring() with only one parameter looks for a given substring from the position given to the end of the string. It expects that the substring extends all the way to the end of the String. For example:

(:div class=code :)

  String stringOne = "Content-Type: text/html";

  // substring(index) looks for the substring from the index position to the end:
  if (stringOne.substring(19) == "html") {
   }


is true, while

  String stringOne = "Content-Type: text/html";

  // substring(index) looks for the substring from the index position to the end:
  if (stringOne.substring(19) == "htm") {
   }


is not true, because there's an l after the htm in the String. (:divend:)

substring() with two parameters looks for a given substring from the first parameter to the second. For example:

(:div class=code :)

  String stringOne = "Content-Type: text/html";

  // you can also look for a substring in the middle of a string:
  if (stringOne.substring(14,18) == "text") {

  } 

(:divend:)

This looks for the word text from positions 14 through 18 of the String.

Caution: make sure your index values are within the String's length or you'll get unpredictable results. This kind of error can be particularly hard to find with the second instance of substring() if the starting position is less than the String's length, but the ending position isn't.

Circuit

(:div class=circuit :) There is no circuit for this example. (:divend:)

Code

(:div class=code :)

(:source




Bookmark and Share