Search whole word in string

前端 未结 4 586
名媛妹妹
名媛妹妹 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:22

    Something like this will work:

    if(/\show\s/i.test(searchOnstring)){
        alert("Found how");
    }
    

    More on the test() method

提交回复
热议问题