【发布时间】:2016-07-01 07:02:25
【问题描述】:
我想要这样:当输入的值与我的数组的值匹配时,写入匹配值。
这是我的代码:
//我的数组如下:
var checkNames = (document.getElementById("KPIorCounterList").value.split("\n").map(element => element.trim())).filter(v=>v != "");
我的另一个数组:myarray= ["RAB Video call drop %",RAB PS R99 drop % ","RAB PS HSDPA drop %"]
例如;将 RAB* 写入 textare 时,我应该看到,以“RAB”开头
我猜,我的代码应该如下:
for (var i = 0; i < checkNames.length; i++) {
for (var j = 0; j < myarray.length; j++) {
// var str = myarray[j].split(" "); // I am not sure for his.
I want to this for here : (pseudo code)
for example checkName[i] == RAB*
if (checkName[i].match("match condition") == myarray[j])
alert(myarray[j]);
//I should show output myarray[j] == RAB Video call drop %",RAB PS R99 drop % ","RAB PS HSDPA drop %"
}
}
我该怎么办? 请..
【问题讨论】:
-
真的没有答案,但我认为
myarray["j"]应该是myarray[j].. -
checkNames 是临时数组吗?
-
不,不同的数组@VladuIonut
-
你的伪代码不是很清楚,里面是临时数组
-
抱歉,我编辑了我的代码。 @VladuIonut
标签: javascript arrays matching string-matching regexp-substr