Liquidsoap provides the string.replace function. But how should I use it? It seems to expect a function as the second argument that does the replacing.
I'd like to do something like this:
str = "Hello world."
str = string.replace(pattern="w", "W", str)
# str == "Hello World."
string.replaceindeed expects a function for the first unlabeled parameter. The return value of that function will be used as a replacement.Example:
The inline arrow function
fun(_) -> "W"is a function that will always return"W".