我從字符串中提取主題標籤是這樣的:提取從字符串中的所有主題標籤#無
const mystring = 'huehue #arebaba,saas #ole #cool asdsad #aaa';
const hashtags = mystring.match(/#\w+/g) || [];
console.log(hashtags);
輸出:
['#arebaba', '#ole', '#cool', '#aaa']
我正則表達式應該如何讓比賽是:
['arebaba', 'ole', 'cool', 'aaa']
我不想使用地圖功能!
的可能的複製[怎麼辦我在JavaScript中檢索正則表達式的所有匹配?](https://stackoverflow.com/問題/ 6323417 /如何檢索所有匹配的正則表達式在JavaScript) – choasia
閱讀正則表達式捕獲組。 http://www.regular-expressions.info/brackets.html –