June 2003
Intermediate to advanced
800 pages
34h 20m
English
You want to replace a certain word or sequence of characters each time it occurs in a string.
Use the String.Replace method.
The String class provides a Replace method that replaces all occurrences of text inside a string, and returns a new string:
Dim Text As String = "The quick brown fox jumps over the lazy dog. " & _
"The quick brown fox jumps over the lazy dog. " & _
"The quick brown fox jumps over the lazy dog. "
Dim ReplacedText As String = Text.Replace("brown", "blue")
' ReplacedText is now "The quick blue fox jumps over the lazy dog."
' repeated identically three times.If you want to replace the occurrence of a pattern in just a portion of the string, you will need ...
Read now
Unlock full access