(searchValue: string | RegExp, replaceValue: string): (
self: string
) => stringReplaces 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"
)transforming
Source effect/String.ts:2632 lines
export const const replace: (
searchValue: string | RegExp,
replaceValue: string
) => (self: string) => 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"
)
replace = (searchValue: string | RegExpsearchValue: string | RegExp, replaceValue: stringreplaceValue: string) => (self: stringself: string): string =>
self: stringself.String.replace(searchValue: string | RegExp, replaceValue: string): string (+3 overloads)Replaces text in a string, using a regular expression or search string.
replace(searchValue: string | RegExpsearchValue, replaceValue: stringreplaceValue)