Package: effect
Module: String
Replaces matches in a string using String.prototype.replace.
Details
String search values and non-global regular expressions replace the first match; global regular expressions replace every match.
Example (Replacing a substring)
import { pipe, String } from "effect"
import * as assert from "node:assert"
assert.deepStrictEqual(pipe("abc", String.replace("b", "d")), "adc")
assert.deepStrictEqual(
pipe("hello world", String.replace("world", "Effect")),
"hello Effect"
)
Signature
declare const replace: (searchValue: string | RegExp, replaceValue: string) => (self: string) => string
Since v2.0.0