stdlib
stdlib copied to clipboard
Consider adding a replace function to regex
trafficstars
My own naive implementation seems a bit slow with larger strings:
fn replace_all(
regex: Result(Regex, CompileError),
input: String,
replacement: String,
) -> String {
let assert Ok(re) = regex
regex.split(re, input)
|> string.join(replacement)
}
I'm hoping the target runtimes have something faster.