7 lines
281 B
TypeScript
7 lines
281 B
TypeScript
|
export const matchAllAndThen = (input: string, pattern: RegExp, callback: (value: string, index: number) => void) => {
|
||
|
[...input.matchAll(pattern)].map(match => {
|
||
|
if (match && match.index !== undefined) {
|
||
|
callback(match[0], match.index);
|
||
|
}
|
||
|
});
|
||
|
}
|