Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/rimbu/typical/mod.ts>Str.ReplaceAll

Rimbu is a TypeScript library focused on immutable, performant, and type-safe collections and other tools.
Go to Latest
type alias Str.ReplaceAll
import { type Str } from "https://deno.land/x/rimbu@1.0.2/typical/mod.ts";
const { ReplaceAll } = Str;

Replaces, in the given string, all matches with Sub with the given Repl.

Examples

Example 1

ReplaceAll<'abcba', 'b', '_'> => 'a_c_a'
ReplaceAll<'abcba', 'b' | 'c', '_'> => 'a___a'

Type Parameters

S extends string
Sub extends string & NonEmptyString<Sub>
Repl extends string
definition: S extends "" ? "" : S extends Append<Sub, infer Rest> ? Append<Repl, ReplaceAll<Rest, Sub, Repl>> : S extends Append<infer Start, infer Rest> ? Append<Start, ReplaceAll<Rest, Sub, Repl>> : never