Regex to allow alphanumeric and dot

前端 未结 3 424
野趣味
野趣味 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:24

    Try using a character class ([…]), like this:

    [\w.]+
    

    For example:

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

提交回复
热议问题