Regex to allow A-Z, - and '

后端 未结 6 2041
情歌与酒
情歌与酒 2021-01-16 21:25

I am trying to get this Regex to work to validate a Name field to only allow A-Z, \' and -.

So far I am using this which is working fine apart from it wont allow an

6条回答
  •  梦毁少年i
    2021-01-16 22:00

    if (preg_match("/^[a-zA-Z -]*$/", $firstname)) {
        // do something here
    }
    

    I have used this, This will work fine. Use It.

提交回复
热议问题