preg匹配特定的十进制字符数

时间:2015-06-02 12:05:50

标签: php preg-match

如何匹配特定数量的十进制字符?

preg_match('/([0-9]{15,16})[^0-9]/', $input, $matches))

实例

no. 05485845150270008225169 => NO MATCH!
no. 50270008225169 => NO MATCH!
FI 150270008225169 => MATCH!
FI 5150270008225169 => MATCH!

1 个答案:

答案 0 :(得分:1)

为模式添加外观,以匹配不超过16位的数字:

(?<!\d)\d{15,16}(?!\d)

https://regex101.com/r/aO0tA5/1