Devendra174's picture
Upload folder using huggingface_hub
1e92f2d verified
export function parseUrlFromText(
text: string,
matcherFunc?: (text: string) => boolean
): string[] {
const linkRegex = /https?:\/\/[^\s/$.?#].[^\s)'"]*/gi
const links = Array.from(text.matchAll(linkRegex), (match) => match[0])
if (matcherFunc) {
return links.filter((link) => matcherFunc(link))
}
return links
}