{
"id": "fn-string-replace",
"dataComponent": "string",
"heading": {
"title": "replace",
"badges": ["String", "PARTIAL"]
},
"synopsis": "Replaces all occurrences of a substring with another substring. Partial/placeholder usage supported.",
"codeBlocks": [
"extend(\"string\")\n\nsput( string:replace(\"l\", \"X\", \"hello\") )\n# => \"heXXo\"\n\n# Partial usage:\nrepL = string:replace(\"l\")\nsput( repL(\"*\")(\"hello\") )\n# => \"he**o\"\n\n# Placeholder:\np = string:replace(_, \"o\", \"foo,boo\")\nsput( p(\",\") )\n# => \"foo boo\""
],
"notes": [
"Arguments: search string, replacement string, input string.",
"Returns a new string.",
"Partial application and _ placeholders supported.",
"If not all are strings, raises an error."
]
}