在正则表达式中包含点(.)和连字符( - )

con*_*mal -2 php regex

 if(preg_match('/[^a-z\-0-9]/i', $value))

    {
    echo "<META HTTP-EQUIV='Refresh' Content='0; URL=http://$ponka/name/error'>";
}
Run Code Online (Sandbox Code Playgroud)

如何在上面的代码中包含一个点和连字符?我知道如何在代码中添加点或连字符if if-yes-then-if-then-else.这段代码是if-no-then-if-then-else(如果你有我想说的话)

Ped*_*ito 7

如果连字符字符类中的第一个或最后一个,则不需要对其进行转义.如果在字符类中,也不需要转义
点,即: hyphen

/[^a-z.0-9-]/i
Run Code Online (Sandbox Code Playgroud)

笔记:

字符类中的元字符是:

^ (negation)
- (range)
] (end of the class)
\ (escape char)
Run Code Online (Sandbox Code Playgroud)