我需要修复这个 preg_match("/^[[0-9]{0,4}$/i", $input)
,它还需要接受负值。谢谢
最佳答案
if (preg_match('/^-?[0-9]{1,4}$/', $subject)) {
# Successful match
} else {
# Match attempt failed
}
关于regex - preg_match 数字负数和正数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5011425/