-
Notifications
You must be signed in to change notification settings - Fork 12
String.Replace
boxgaming edited this page Aug 5, 2025
·
2 revisions
Returns a new string with all matches of a pattern replaced by a replacement. The pattern can be a string or a regular expression.
result$ = String.Replace (s$, searchStr$, replaceStr$ [, regex%])
- The s$ parameter contains the source string.
- The searchStr$ indicates the search pattern used to locate the values to replace in the given string s$.
- The replaceStr$ parameter contains the replacement value.
- If true (non-zero) the optional regex% parameter indicates that the searchStr$ parameter should be evaluated as a regular expression. By default, it will be treated as a plain string.
Import String From "lib/lang/string.bas"
Dim s As String
s = "The quick brown fox jumped over the lazy dog. It barked."
s2 = String.Replace(s, "fox", "wolf")
s2 = String.Replace(s2, "dog", "coyote")
Print s2
s2 = String.Replace(s, "fox|dog", "animal", -1)
Print s2The quick brown wolf jumped over the lazy coyote. It barked.
The quick brown animal jumped over the lazy animal. It barked.