Checking String for illegal characters using regular expression

后端 未结 5 1771
猫巷女王i
猫巷女王i 2021-01-25 21:02

I want to check a for any illegal character using the following regular expression in PHP. Essentially, I want to allow only alphanumeric and underscore (_). Unfortunately the

5条回答
  •  耶瑟儿~
    2021-01-25 22:01

    You need to anchor it at the end too, instead of just checking the first character. Try "/^[-a-z0-9_]*$/i" instead.

提交回复
热议问题