Tutorial.StringReplace History

Hide minor edits - Show changes to output

August 27, 2015, at 01:17 PM by Simone Maiocchi -
Changed lines 1-6 from:
(:div class=breadcrumb:)
[[Tutorial.HomePage | Tutorials]] > [[Tutorial.Examples | Examples]] > Strings > StringReplace
(:divend:)

(:*toc:)
to:
(:html:)

<div class="subHeader row">

<div class="breadcrumb columns large-10 medium-10">
<p>
<a class="wikilink" href="/en/Tutorial/HomePage">Tutorials </a>
> <a class="wikilink" href="/en/Tutorial/BuiltInExamples"> Built-In Examples </a> > 08.Strings > StringReplace
</p>
</div>
</div>

(:htmlend:)

Changed lines 54-66 from:
* [[Reference/StringObject|String object]]
* [[StringConstructors]]
* [[StringAdditionOperator]]
* [[StringIndexOf]]
* [[StringAppendOperator]]
* [[StringLengthTrim]]
* [[StringCaseChanges]]
* [[StringReplace]]
* [[StringCharacters]]
* [[StringStartsWithEndsWith]]
* [[StringComparisonOperators]]
* [[StringSubstring]]
to:
* [[Reference/StringObject|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.
August 11, 2015, at 11:08 AM by Simone Maiocchi -
Changed lines 18-19 from:
There is no circuit for this example, though your board must be connected to your computer via USB.
to:
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.
Changed lines 58-59 from:

to:
\\
''Last Revision 2015/08/11 by SM''
July 10, 2015, at 01:55 PM by Simone Maiocchi -
July 10, 2015, at 01:49 PM by Simone Maiocchi -
Changed lines 1-9 from:
''Examples > Strings''

!!!String replace Function

The [[Reference/StringObject| '''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.

(:div class=BOM :)
!!!Hardware Required
* Arduino Board
to:
(:div class=breadcrumb:)
[[Tutorial.HomePage | Tutorials]] &gt; [[Tutorial.Examples | Examples]] &gt; Strings &gt; StringReplace
Added lines 5-15:
(:*toc:)

!!String replace Function

The [[Reference/StringObject| '''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.

(:div class=BOM :)
!!!Hardware Required
* Arduino or Genuino Board
(:divend:)
Changed lines 18-19 from:
There is no circuit for this example, though your Arduino must be connected to your computer via USB.
to:
There is no circuit for this example, though your board must be connected to your computer via USB.
Changed lines 30-31 from:
(:div class=code :)
(:source lang=arduino tabwidth=4:)
to:
[@
Changed lines 33-40 from:
(:sourceend:)
to:
@]

In this case, the code will compile, but @@stringOne@@ will remain unchanged, since the replacement substring is more than the String itself.

(:div class=code :)

(:source https://raw.githubusercontent.com/arduino/Arduino/master/build/shared/examples/08.Strings/StringReplace/StringReplace.ino lang=arduino tabwidth=4:)
Changed lines 43-52 from:
In this case, the code will compile, but stringOne will remain unchanged, since the replacement substring is more than the String itself.

(:div class=code :)

(:source https://raw.githubusercontent.com/arduino/Arduino/master/build/shared/examples/08.Strings/StringReplace/StringReplace.ino lang=arduino tabwidth=4:)

(:divend:)

!!!See Also:
to:
!!!See Also
May 02, 2012, at 03:54 PM by Scott Fitzgerald -
Changed lines 37-38 from:
(:source https://raw.githubusercontent.com/arduino/Arduino/master/build/shared/examples/8.Strings/StringReplace/StringReplace.ino lang=arduino tabwidth=4:)
to:
(:source https://raw.githubusercontent.com/arduino/Arduino/master/build/shared/examples/08.Strings/StringReplace/StringReplace.ino lang=arduino tabwidth=4:)
November 16, 2011, at 04:22 AM by Scott Fitzgerald -
Changed lines 37-38 from:
(:source https://raw.githubusercontent.com/arduino/Arduino/master/build/shared/examples/8.Strings/StringReplace/StringReplace.pde lang=arduino tabwidth=4:)
to:
(:source https://raw.githubusercontent.com/arduino/Arduino/master/build/shared/examples/8.Strings/StringReplace/StringReplace.ino lang=arduino tabwidth=4:)
September 19, 2010, at 11:52 PM by Christian Cerrito -
Changed lines 5-6 from:
The [[Reference/StringObject|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.
to:
The [[Reference/StringObject| '''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.
September 19, 2010, at 11:51 PM by Christian Cerrito -
Changed lines 5-6 from:
The [[Reference/StringObject|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.
to:
The [[Reference/StringObject|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.
September 19, 2010, at 11:51 PM by Christian Cerrito -
Added line 23:
!!!Code
Deleted line 34:
!!!Code
September 19, 2010, at 11:50 PM by Christian Cerrito -
Changed line 9 from:
No external hardware is required.
to:
* Arduino Board
Deleted lines 11-22:

'''Caution:'''
If you try to replace a substring that's more than the whole string itself, nothing will be replaced. For example:
(:div class=code :)
(:source lang=arduino tabwidth=4:)
String stringOne = "<html><head><body>";
String stringTwo = stringOne.replace("<html><head></head><body></body></html>", "Blah");
(:sourceend:)
(:divend:)

In this case, the code will compile, but stringOne will remain unchanged, since the replacement substring is more than the String itself.
Deleted line 12:
Changed lines 14-18 from:
There is no circuit for this example.
to:
There is no circuit for this example, though your Arduino must be connected to your computer via USB.

%height=250px%[[Attach:Arduino_bb.png | Attach:Arduino_bb.png]]
[-image developed using [[http://www.fritzing.org |Fritzing]]. For more circuit examples, see the [[http://fritzing.org/projects/|Fritzing project page]] -]
Changed lines 21-24 from:
!!!Code
to:


'''Caution:'''
If you try to replace a substring that's more than the whole string itself, nothing will be replaced. For example:
Changed lines 26-28 from:

(:source https://raw.githubusercontent.com/arduino/Arduino/master/build/shared/examples/8.Strings/StringReplace/StringReplace.pde lang=arduino tabwidth=4:)
to:
(:source lang=arduino tabwidth=4:)
String stringOne = "<html><head><body>";
String stringTwo = stringOne.replace("<html><head></head><body></body></html>", "Blah");
(:sourceend:)
Added lines 32-40:
In this case, the code will compile, but stringOne will remain unchanged, since the replacement substring is more than the String itself.

!!!Code
(:div class=code :)

(:source https://raw.githubusercontent.com/arduino/Arduino/master/build/shared/examples/8.Strings/StringReplace/StringReplace.pde lang=arduino tabwidth=4:)

(:divend:)
Added line 42:
Added lines 55-57:


September 16, 2010, at 10:53 PM by Tom Igoe -
Changed lines 16-17 from:
(:source lang=arduino tabwidth=4:) String stringOne = "<html><head><body>";
to:
(:source lang=arduino tabwidth=4:)
String stringOne = "<html><head><body>";
September 16, 2010, at 10:52 PM by Tom Igoe -
Changed line 33 from:
to:
September 16, 2010, at 10:52 PM by Tom Igoe -
Changed lines 16-17 from:
[@
String stringOne = "<html><head><body>";
to:
(:source lang=arduino tabwidth=4:) String stringOne = "<html><head><body>";
Changed line 18 from:
@]
to:
(:sourceend:)
Changed line 32 from:
(:source https://raw.githubusercontent.com/arduino/Arduino/master/build/shared/examples/8.Strings/StringReplace/StringReplace.pde lang=arduino tabwidth=4:)
to:
(:source https://raw.githubusercontent.com/arduino/Arduino/master/build/shared/examples/8.Strings/StringReplace/StringReplace.pde lang=arduino tabwidth=4:)
August 01, 2010, at 05:01 PM by Tom Igoe -
Added lines 1-49:
''Examples > Strings''

!!!String replace Function

The [[Reference/StringObject|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.

(:div class=BOM :)
!!!Hardware Required
No external hardware is required.
(:divend:)


'''Caution:'''
If you try to replace a substring that's more than the whole string itself, nothing will be replaced. For example:
(:div class=code :)
[@
String stringOne = "<html><head><body>";
String stringTwo = stringOne.replace("<html><head></head><body></body></html>", "Blah");
@]
(:divend:)

In this case, the code will compile, but stringOne will remain unchanged, since the replacement substring is more than the String itself.

!!!Circuit

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

!!!Code
(:div class=code :)

(:source

Share