Regex to allow A-Z, - and '

后端 未结 6 2189
情歌与酒
情歌与酒 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条回答
  •  我在风中等你
    2021-01-16 22:06

    Your regexp should look like this:

    preg_match("/^[A-Z\'-]+$/",$firstname);
    

    maches: AB A-B AB-'

    does not match: Ab a-B AB#

提交回复
热议问题