【发布时间】:2020-08-06 05:12:29
【问题描述】:
我需要一些用于 Vue 应用程序的简单 javascript 代码,它将一个字符串拆分为一个数组并检查是否有任何值在不同的字符串中。
我有
let AffiliationString = " This person goes to Stony Brook"
let affiliation = "Stony Brook OR Stony Brook University OR The University of Washington"
let affiliations = affiliation.toLowerCase().split(" or ");
affiliation = affiliations.join(",");
let regexList = [ affiliation ];
let isMatch = regexList.some(rx => rx.test(AffiliationString));
我想看看数组中是否有任何项目在“AffiliationString”字符串中
当我这样做时,我得到以下错误
Uncaught (in promise) TypeError: rx.test is not a function
我在 StackOverflow 上看到了许多检查数组是否存在值的示例,但反之则不然。 我正在尝试使用 javascript - match regular expression against the array of items
我在一个 Vue 项目中使用
"eslint": "6.7.2",
我需要为数组中的每个值重做一个循环吗?
感谢您的帮助
【问题讨论】:
标签: javascript vue.js es6-promise