Search whole word in string

前端 未结 4 587
名媛妹妹
名媛妹妹 2020-12-18 09:48

I am looking for a function written in javascript ( not in jquery) which will return true if the given word exactly matches ( should not be case sensitive).

like..

4条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-18 10:40

    Try this:

    var s = 'string to check', ss= 'to';
    if(s.indexOf(ss) != -1){
      //output : true
    }
    

提交回复
热议问题