How to match exact word anywhere in string with PHP regexp

后端 未结 4 707
醉梦人生
醉梦人生 2021-01-27 11:15

I want to find out if user has used the words admin or username anywhere in their possible username string.

So if user wants to use admin

4条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-27 12:14

    This might be the pattern that you're looking for:

    '#(^|\s){1}('. $needle .')($|\s|,|\.){1}#i'
    

    Some details depend on the restrictions that you want to apply.

提交回复
热议问题