@str.replace
Replace all occurrences of a substring.
Returns: string
Syntax
Section titled “Syntax”@str.replace(s old replacement)Arguments
Section titled “Arguments”| Name | Type | Description |
|---|---|---|
s |
string |
Source string |
old |
string |
Substring to match |
replacement |
string |
Replacement text |
Examples
Section titled “Examples”# Replace all occurrencesset $s @str.replace("foo-bar-baz" "-" "_")
# Remove a substringset $s @str.replace("hello world" " world" "")See Also
Section titled “See Also”- @str.includes — check for substring
- @str.split — split by delimiter