core: add getRelatedUsers

This commit is contained in:
undefined committed 2021-04-20 13:06:49 +08:00
1 parent fc251d1124
commit 915c01f703
2 files changed
+13 -2

No files matched your search

+10
View File
@@ -32,4 +32,14 @@ export function logAndReturn(logger: Logger) {
};
}
const RE_USER = /(?:^|\s)(@)([^ ]{3,255}?)(?=\s|$)/g;
export function getRelatedUsers(content: string) {
const results = [];
let res: string[];
// eslint-disable-next-line no-cond-assign
while (res = RE_USER.exec(content)) results.push(res[2]);
return results;
}
export * from '@hydrooj/utils/lib/utils';