Hide minor edits - Show changes to markup
(:div class=code :)
(:div class=code :)
(:source http://github.com/arduino/Arduino/raw/master/build/shared/examples/8.Strings/StringLength/StringLength.ino lang=arduino tabwidth=4:)
(:source http://github.com/arduino/Arduino/raw/master/build/shared/examples/08.Strings/StringLength/StringLength.ino lang=arduino tabwidth=4:)
(:source http://github.com/arduino/Arduino/raw/master/build/shared/examples/8.Strings/StringLengthTrim/StringLengthTrim.ino lang=arduino tabwidth=4:)
(:source http://github.com/arduino/Arduino/raw/master/build/shared/examples/08.Strings/StringLengthTrim/StringLengthTrim.ino lang=arduino tabwidth=4:)
(:source http://github.com/arduino/Arduino/raw/master/build/shared/examples/8.Strings/StringLength/StringLength.pde lang=arduino tabwidth=4:)
(:source http://github.com/arduino/Arduino/raw/master/build/shared/examples/8.Strings/StringLength/StringLength.ino lang=arduino tabwidth=4:)
(:source http://github.com/arduino/Arduino/raw/master/build/shared/examples/8.Strings/StringLengthTrim/StringLengthTrim.pde lang=arduino tabwidth=4:)
(:source http://github.com/arduino/Arduino/raw/master/build/shared/examples/8.Strings/StringLengthTrim/StringLengthTrim.ino lang=arduino tabwidth=4:)
(:div class=code :)
(:div class=code :)
No external hardware is required.
(: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:)
(:div class=code :)
(:div class=code :)
(:source http://github.com/arduino/Arduino/raw/master/build/shared/examples/8.Strings/StringLengthTrim/StringLengthTrim.pde lang=arduino tabwidth=4:)
(:source http://github.com/arduino/Arduino/raw/master/build/shared/examples/8.Strings/StringLengthTrim/StringLengthTrim.pde lang=arduino tabwidth=4:)
@@trim() is useful for when you know there are extraneous whitespace characters on the beginning or the end of a String and you want to get rid of them. Whitespace refers to characters that take space but aren't seen. It includes the single space (ASCII 32), tab (ASCII 9), vertical tab (ASCII 11), form feed (ASCII 12), carriage return (ASCII 13), or newline (ASCII 10). The example below shows a String with whitespace, before and after trimming:
trim() is useful for when you know there are extraneous whitespace characters on the beginning or the end of a String and you want to get rid of them. Whitespace refers to characters that take space but aren't seen. It includes the single space (ASCII 32), tab (ASCII 9), vertical tab (ASCII 11), form feed (ASCII 12), carriage return (ASCII 13), or newline (ASCII 10). The example below shows a String with whitespace, before and after trimming:
[@
@]
Examples > Strings
You can get the length of a Strings using the length() command, or eliminate extra characters using the trim() command. This example shows you how to use both commands.
(:div class=BOM :)
No external hardware is required. (:divend:)
length() returns the length of a String. There are many occasions when you need this. For example,if you wanted to make sure a String was less than 140 characters, to fit it in a text message, you could do this:
(:div class=code :)
(:source http://github.com/arduino/Arduino/raw/master/build/shared/examples/8.Strings/StringLength/StringLength.pde lang=arduino tabwidth=4:)
(:divend:)
@@trim() is useful for when you know there are extraneous whitespace characters on the beginning or the end of a String and you want to get rid of them. Whitespace refers to characters that take space but aren't seen. It includes the single space (ASCII 32), tab (ASCII 9), vertical tab (ASCII 11), form feed (ASCII 12), carriage return (ASCII 13), or newline (ASCII 10). The example below shows a String with whitespace, before and after trimming:
(:div class=code :)
(:source