确定字符串是否有子字符串(单词)

编程入门 行业动态 更新时间:2024-10-28 10:21:51
本文介绍了确定字符串是否有子字符串(单词)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我尝试使用条件来验证字符串是否包含某个单词,例如:我想使用方法(正则表达式?)来查找字符串是否包含 & 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) { ....

更多推荐

确定字符串是否有子字符串(单词)

本文发布于:2023-10-29 20:40:52,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1540695.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:字符串   单词

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!