export type RegexHandler = (matchedRegexIndex: number, match: RegExpMatchArray) => Promise; export async function parseTextWithRegexList(text: string, regexList: RegExp[], handler: RegexHandler) : Promise { for (let i = 0; i < regexList.length; ++i) { const regex = regexList[i]!; const match = text.match(regex); if (!match) { continue; } return await handler(i, match); } return null; }