Skip to content

replaceWithFunction

replaceWithFunction(string, pattern, fn) → string · String

Replace all matches of a pattern using a function to compute the replacement.

  • string (required): the source string

  • pattern (required): regex pattern

  • fn (required): lambda (match) -> replacement

utlx
replaceWithFunction("hello world", "[a-z]+", (m) -> upper(m))
// "HELLO WORLD"

Released under AGPL-3.0.