2022-01-02 22:53:20 +00:00
|
|
|
import _ from 'lodash'
|
|
|
|
|
2021-12-31 19:41:37 +00:00
|
|
|
export function parseTags(text: string) {
|
|
|
|
const regex = /(?:^|\s)(?:[#][a-z0-9_]+)/gi
|
2022-01-02 22:53:20 +00:00
|
|
|
const matches = (text.match(regex) || []).map((match) =>
|
|
|
|
match.trim().substring(1)
|
|
|
|
)
|
|
|
|
return _.uniqBy(matches, (tag) => tag.toLowerCase())
|
2021-12-31 19:41:37 +00:00
|
|
|
}
|