Regex to allow alphanumeric and dot

前端 未结 3 426
野趣味
野趣味 2020-12-11 21:15

Hi I have a variable in a Silex route and we only allow alphanumeric values

->assert(\'hash\',\'\\w+\')

I would like to also allow a dot

3条回答
  •  难免孤独
    2020-12-11 21:23

    I don't know the internals of assert(), but use a char class:

    ->assert('hash','[\w.]+')
    

提交回复
热议问题