Checking String for illegal characters using regular expression

后端 未结 5 1727
猫巷女王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 21:57

    Your expression matches only 1 character. Try /^[-a-z0-9_]+$/i the '+' matches more then 1 character and the '$' is the end of line anchor

提交回复
热议问题