include dot(.) and hyphen(-) in a regex

后端 未结 4 1146
误落风尘
误落风尘 2021-01-29 12:56
 if(preg_match(\'/[^a-z\\-0-9]/i\', $value))

    {
    echo \"\";
}

how

4条回答
  •  我在风中等你
    2021-01-29 13:18

    The hyphen is already in there, simply add an escaped dot using \..

    /edit: But as noted in the comment the escaping isn't needed.

提交回复
热议问题