manifold/web/lib/util/parse.ts

9 lines
228 B
TypeScript
Raw Normal View History

2021-12-31 19:41:37 +00:00
export function parseTags(text: string) {
const regex = /(?:^|\s)(?:[#][a-z0-9_]+)/gi
const matches = text.match(regex) || []
return matches.map((match) => {
const tag = match.trim().substring(1)
return tag
})
}