String.Replace Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
Replace(ICharSequence, ICharSequence) |
Replaces each substring of this string that matches the literal target sequence with the specified literal replacement sequence. |
Replace(Char, Char) |
Returns a string resulting from replacing all occurrences of
|
Replace(String, String) |
Replaces each substring of this string that matches the literal target sequence with the specified literal replacement sequence. |
Replace(ICharSequence, ICharSequence)
Replaces each substring of this string that matches the literal target sequence with the specified literal replacement sequence.
[Android.Runtime.Register("replace", "(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Ljava/lang/String;", "")]
public string Replace (Java.Lang.ICharSequence target, Java.Lang.ICharSequence replacement);
[<Android.Runtime.Register("replace", "(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Ljava/lang/String;", "")>]
member this.Replace : Java.Lang.ICharSequence * Java.Lang.ICharSequence -> string
Parameters
- target
- ICharSequence
The sequence of char values to be replaced
- replacement
- ICharSequence
The replacement sequence of char values
Returns
The resulting string
- Attributes
Exceptions
if target
or replacement
is null
.
Remarks
Replaces each substring of this string that matches the literal target sequence with the specified literal replacement sequence. The replacement proceeds from the beginning of the string to the end, for example, replacing "aa" with "b" in the string "aaa" will result in "ba" rather than "ab".
Added in 1.5.
Java documentation for java.lang.String.replace(java.lang.CharSequence, java.lang.CharSequence)
.
Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.
Applies to
Replace(Char, Char)
Returns a string resulting from replacing all occurrences of
oldChar
in this string with newChar
.
[Android.Runtime.Register("replace", "(CC)Ljava/lang/String;", "")]
public string Replace (char oldChar, char newChar);
[<Android.Runtime.Register("replace", "(CC)Ljava/lang/String;", "")>]
member this.Replace : char * char -> string
Parameters
- oldChar
- Char
the old character.
- newChar
- Char
the new character.
Returns
a string derived from this string by replacing every
occurrence of oldChar
with newChar
.
- Attributes
Remarks
Returns a string resulting from replacing all occurrences of oldChar
in this string with newChar
.
If the character oldChar
does not occur in the character sequence represented by this String
object, then a reference to this String
object is returned. Otherwise, a String
object is returned that represents a character sequence identical to the character sequence represented by this String
object, except that every occurrence of oldChar
is replaced by an occurrence of newChar
.
Examples: <blockquote>
"mesquite in your cellar".replace('e', 'o')
returns "mosquito in your collar"
"the war of baronets".replace('r', 'y')
returns "the way of bayonets"
"sparring with a purple porpoise".replace('p', 't')
returns "starring with a turtle tortoise"
"JonL".replace('q', 'x') returns "JonL" (no change)
</blockquote>
Java documentation for java.lang.String.replace(char, char)
.
Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.
Applies to
Replace(String, String)
Replaces each substring of this string that matches the literal target sequence with the specified literal replacement sequence.
public string Replace (string target, string replacement);
member this.Replace : string * string -> string
Parameters
- target
- String
The sequence of char values to be replaced
- replacement
- String
The replacement sequence of char values
Returns
The resulting string
Remarks
Replaces each substring of this string that matches the literal target sequence with the specified literal replacement sequence. The replacement proceeds from the beginning of the string to the end, for example, replacing "aa" with "b" in the string "aaa" will result in "ba" rather than "ab".
Added in 1.5.
Java documentation for java.lang.String.replace(java.lang.CharSequence, java.lang.CharSequence)
.
Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.