[英]codeigniter regex_match matching for 'two length values'
I have this regex_match like - 我有这样的regex_match-
regex_match[/^[0-9]{13}$/ ]
It validates all 13-digit integers. 它验证所有13位整数。 But I can't seem to find a way for allowing only 10-digit and 13-digit integers to pass as input.
但是我似乎找不到找到只允许10位和13位整数作为输入传递的方法。 I tried all kinds of code like
我尝试了各种代码,例如
regex_match[/^[0-9]{13|10}$/ ] ,
regex_match[/^[0-9]{13}{10}$/ ]
and even 乃至
regex_match[/^[0-9]{13}$/ ] | regex_match[/^[0-9]{10}$/ ]
but none of them is working. 但他们都不在工作。 How can I achieve this ?
我该如何实现?
Try 尝试
regex_match[/^([0-9]{13}|[0-9]{10})$/]
You might need to escape the brackets. 您可能需要转括号。
Check this..This is tested.. 检查一下。这已经过测试。
$number="12541254192";
if( preg_match('/^([0-9]{13}|[0-9]{10})$/', number)==1){
echo "Matching";
}else{
echo "Not Matching";
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.