Skip to main content

2070 - Drop Char

Answer TestCases

从字符串中剔除指定字符。

例如:

type Butterfly = DropChar<' b u t t e r f l y ! ', ' '> // 'butterfly!'

Solution

type DropChar<S, C extends string> = S extends `${infer L}${C}${infer R}`
? DropChar<`${L}${R}`, C>
: S