我有 JavaScript 文件
这是文件的一部分
a().initLibrary({
controls: [
"aa","bb"],
elements: []
});
例如,我想检查控件中是否存在输入参数
var search1 = "dd" the result should be false
var search2 = "aa" the result should be true
这是在控件中查找数据的正则表达式:
controls\s*:\s*\[([^\]]*) - the result is the data of the controls
我如何检查正则表达式的结果中是否存在serach1或serach2,而无需使用字符串检查结果并根据“,”拆分它。 我可以将参数插入正则表达式吗?
最佳答案
关于javascript - 如何向正则表达式插入参数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28135072/