@monstermann/fn
Version:
A utility library for TypeScript.
25 lines (23 loc) • 844 B
TypeScript
import { Replace } from "string-ts";
//#region src/string/replace.d.ts
/**
* `replace(target, search, replace)`
*
* Replaces the first occurrence of `search` string or regular expression in `target` string with `replace` string.
*
* ```ts
* replace("hello world", "world", "universe"); // "hello universe"
* replace("hello world", /o/g, "0"); // "hell0 w0rld"
* ```
*
* ```ts
* pipe("hello world", replace("world", "universe")); // "hello universe"
* pipe("hello world", replace(/o/g, "0")); // "hell0 w0rld"
* ```
*/
declare const replace: {
<U extends string | RegExp, V extends string>(search: U, replacement: V): <T extends string>(target: T) => Replace<T, U, V>;
<T extends string, U extends string | RegExp, V extends string>(target: T, search: U, replacement: V): Replace<T, U, V>;
};
//#endregion
export { replace };