stdlib icon indicating copy to clipboard operation
stdlib copied to clipboard

Consider adding a replace function to regex

Open fwgreen opened this issue 1 year ago • 2 comments
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.

fwgreen avatar Jun 04 '24 19:06 fwgreen