您好我正在编写一个脚本来将一些字符串替换为一个名为text的数组,如下所示:
Tensor("Placeholder:0", shape=TensorShape([Dimension(None), Dimension(784)]), dtype=float32)
Tensor("Softmax:0", shape=TensorShape([Dimension(None), Dimension(10)]), dtype=float32)
tensorflow.python.ops.variables.Variable object at 0x1006b0b90>
tensorflow.python.ops.variables.Variable object at 0x101b76410>
我要替换的单词存储在一个名为的数组中: colorWords:
var text = document.getElementById("texto").value;
我想创建一个名为:tagText的数组,它包含一个名为tagText的新数组,并替换了一些字符串。
var colorWords = Object.keys(filtered)
为了达到这个目的,我试过了:
tagText=[];
但是自从我得到这个方法后我就失败了:
for (i = 0; i < colorWords.length; i++) {
tagText.push(text.replace(/colorWords[i]/g, "<p><font color=\"red\">TEXT</font></p>"));
}
console.log(tagText)
哪个错误,因为它没有将数组callde colorWords中包含的单词替换为新字符串,我想感谢任何实现此目的的建议。 我的完整代码如下所示:
[""RBD|X|RBD3|C|92173~GJHGWO.NAYE" "SAMBORNSiPOSSSTH…X3|RBD|C|92173~GJHGXC.NAYE" "SAMBORNSiPOSSSTHRa"↵", ""RBD|X|RBD3|C|92173~GJHGWO.NAYE" "SAMBORNSiPOSSSTH…X3|RBD|C|92173~GJHGXC.NAYE" "SAMBORNSiPOSSSTHRa"↵", ""RBD|X|RBD3|C|92173~GJHGWO.NAYE" "SAMBORNSiPOSSSTH…X3|RBD|C|92173~GJHGXC.NAYE" "SAMBORNSiPOSSSTHRa"↵", ""RBD|X|RBD3|C|92173~GJHGWO.NAYE" "SAMBORNSiPOSSSTH…X3|RBD|C|92173~GJHGXC.NAYE" "SAMBORNSiPOSSSTHRa"↵", ""RBD|X|RBD3|C|92173~GJHGWO.NAYE" "SAMBORNSiPOSSSTH…X3|RBD|C|92173~GJHGXC.NAYE" "SAMBORNSiPOSSSTHRa"↵", ""RBD|X|RBD3|C|92173~GJHGWO.NAYE" "SAMBORNSiPOSSSTH…X3|RBD|C|92173~GJHGXC.NAYE" "SAMBORNSiPOSSSTHRa"↵", ""RBD|X|RBD3|C|92173~GJHGWO.NAYE" "SAMBORNSiPOSSSTH…X3|RBD|C|92173~GJHGXC.NAYE" "SAMBORNSiPOSSSTHRa"↵", ""RBD|X|RBD3|C|92173~GJHGWO.NAYE" "SAMBORNSiPOSSSTH…X3|RBD|C|92173~GJHGXC.NAYE" "SAMBORNSiPOSSSTHRa"↵", ""RBD|X|RBD3|C|92173~GJHGWO.NAYE" "SAMBORNSiPOSSSTH…X3|RBD|C|92173~GJHGXC.NAYE" "SAMBORNSiPOSSSTH