/** * Replace all occurrences of a string in another string with a new string. * * @template T The string to search. * @template S The string to replace. * @template R The string to replace with. * @returns The result string. * @example StringReplace<'~1user~1profile', '~1', '/'> // => '/user/profile' */ type StringReplace = T extends `${infer A}${S}${infer B}` ? StringReplace<`${A}${R}${B}`, S, R> : T; export type { StringReplace };