FindAll
约 133 字小于 1 分钟
2026-02-11
题目
Given a pattern string P and a text string T, implement the type FindAll<T, P> that returns an Array that contains all indices (0-indexed) from T where P matches.
解题思路
待补充
答案
type FindAll<T extends string, P extends string> = any验证
import type { Equal, Expect } from '@type-challenges/utils'
type cases = [
Expect<Equal<FindAll<'Collection of TypeScript type challenges', 'Type'>, [14]>>,
Expect<Equal<FindAll<'Collection of TypeScript type challenges', 'pe'>, [16, 27]>>,
Expect<Equal<FindAll<'Collection of TypeScript type challenges', ''>, []>>,
Expect<Equal<FindAll<'', 'Type'>, []>>,
Expect<Equal<FindAll<'', ''>, []>>,
Expect<Equal<FindAll<'AAAA', 'A'>, [0, 1, 2, 3]>>,
Expect<Equal<FindAll<'AAAA', 'AA'>, [0, 1, 2]>>,
]参考
无
