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.ReplaceLast

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

Replaces, in the given string, the last match with Sub with the given Repl. Returns never if there was no match.

Examples

Example 1

ReplaceLast<'abcba', 'b', '_'> => 'abc_a'
ReplaceLast<'abcba', 'b' | 'c', '_'> => 'abc_a'

Type Parameters

S extends string
Sub extends string & NonEmptyString<Sub>
Repl extends string
definition: ReplaceLastHelper<S, Sub, Repl, false>