任何帮助都将受到赞赏:在我弄清楚我做错了之前,我无法继续前进..
我正在使用for
循环在某些文本中搜索名称,然后尝试将这些字母推送到数组中。由于某种原因,它不是推动,我不确定我做错了什么..仍然是一个新的... thx的帮助!
var text = "Code it out bro, it will just get Zane Zane Zane better
from here, especially after your familiar with the various
frameworks..yeah man...";
var hits = [ ];
var nameZane = "Zane";
for (i=0; i < text.length; i++)
if (i === "Z"){
for (j=i; j < nameZane.length + i; j++){
hits.push(text[j])}
}
if (hits.length === 0){
console.log("Couldn't find " + nameZane)}
else{
console.log(hits)}
答案 0 :(得分:0)
如果条件i
text[i]
不是if (text[i] === "Z") {
使用此var text = "Code it out bro, it will just get Zane Zane Zane better from here, especially after your familiar with the variousframeworks..yeah man...";
var hits = [];
var nameZane = "Zane";
for (i = 0; i < text.length; i++)
if (text[i] === "Z") {
for (j = i; j < nameZane.length + i; j++) {
hits.push(text[j])
}
}
if (hits.length == 0) {
console.log("What the f*** man?")
} else {
console.log(hits)
}
Update fp
set fp.Address_Id=al.AddressID_new
from [dbo].[fact_P] fp join AddressLookup al
on fp.Address_Id= al.AddressID_old
答案 1 :(得分:0)
编辑您的代码:
if (i === "Z")
到
if (text.charAt(i) == 'Z')
AND
hits.push(text[j])
到
hits.push(text.charAt(j));
答案 2 :(得分:0)
var re = /Zane/g,
str = "Code it out bro, it will just get Zane Zane Zane better from here, especially after your familiar with the various frameworks..yeah man...";
while ((match = re.exec(str)) != null) {
console.log("match found at " + match.index);
}