Skip to content
Reference > Methods

strReplace(text,find,replace)

Definition

String strReplace(String text, String find, String replace)

Description

Given a string, this method finds and replaces all occurences of substring with another substring, and returns the resulting string.

Parameter Definition

Name Type Description
text String String to look look for matching substring(find param) in
find String String to look for in text, literal not a pattern
replace String When find string is found, replace with this string

Examples

1
2
3
4
String r1 = strReplace("cat in the hat","at","an"); // r1 == can in the han
String r2 = strReplace("tististis","tis","a"); // r2 == aaa
String r3 = strReplace("Some example","",","); // r3 == Some example
String r4 = strReplace("Several\nlines\nare\none\nline","\n"," "); // r4 == Several lines are one line