我想测试文本中的每个单词是否以字符 # 开头,如果是,我会将单词放入变量“response”中,如果不是,我将继续搜索。我尝试了类似的东西:
var found = false;
for (i = 0; i < text.length; i++) {
     if (found = /^#...$/.test(text[i])) {
        found = true;
     }
     if (found== true){
          //other stuff
     }
}
你能帮我做这个吗?