本文介绍了确定字符串是否有子字符串(单词)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试使用条件来验证字符串是否包含某个单词,例如:我想使用方法(正则表达式?)来查找字符串是否包含 & SWE> clickable。
I try to use a conditional to verify if a string contain a certain word, for example: I want to use a method (regex?) to find if a string has the text "&SWE>clickable".
var text1 = "layer_legs"; var text2 = "layer_head&SWE>clickable"; if (....) document.write ("the layer is clickable") else document.write ("the layer is not clickable")我该怎么做?
推荐答案if (text2.indexOf("&SWE>clickable") > -1) { ....
更多推荐
确定字符串是否有子字符串(单词)
发布评论