manifold/web/lib/util/parse.ts
2022-01-02 16:53:20 -06:00

10 lines
262 B
TypeScript

import _ from 'lodash'
export function parseTags(text: string) {
const regex = /(?:^|\s)(?:[#][a-z0-9_]+)/gi
const matches = (text.match(regex) || []).map((match) =>
match.trim().substring(1)
)
return _.uniqBy(matches, (tag) => tag.toLowerCase())
}