以下代码应该能够找到匹配但却没有。在线正则表达式测试站点能够找到匹配项。试试http://www.regexplanet.com/advanced/php/index.html。我的代码出了什么问题?
<?php
if (preg_match("[a-zA-Z0-9]{1,200}\.[a-zA-Z0-9]{1,10}", "abc.jpg")) {
echo "A match was found.";
} else {
echo "A match was not found.";
}
?>
结果:
A match was not found