这就是我想要做的。老实说,我什至不知道从哪里开始。
var text1 = 'ThE foX iS brown',
text2 = 'the fox is brown the fox is brown THE FOX IS BROWN',
index = text2.toLowerCase().indexOf(text1.toLowerCase()),
output = 'do something with substring?';
alert(index);
“text2”应更改为: The fox is brown the fox is brown THE FOX IS BROWN
var text1 = 'ThE foX iS brown the FOX is BrO',
text2 = 'the fox is brown the fox is brown THE FOX IS BROWN',
index = text2.toLowerCase().indexOf(text1.toLowerCase()),
output = 'do something with substring?';
alert(index);
在这种情况下,“text2”应更改为:狐狸是棕色的狐狸是棕色的狐狸是棕色的
我想也许我应该首先尝试在“text2”中找到字符串“text1”的“第一次”出现,但它似乎不起作用?我想在那之后我可以使用substring
?或者也许有更简单的方法来做到这一点?我不确定。任何帮助将非常感激。谢谢你。