UNPKG

regexkit

Version:

A useful regex toolkit for validation, extraction, and escaping in JavaScript/TypeScript.

4 lines (3 loc) 295 B
export const extractHashtags = (text) => [...text.matchAll(/#\w+/g)].map((match) => match[0]); export const extractMentions = (text) => [...text.matchAll(/@\w+/g)].map((match) => match[0]); export const extractNumbers = (text) => [...text.matchAll(/\b\d+(\.\d+)?\b/g)].map((match) => match[0]);