Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我探索了互联网,但找不到一个例子。而且我在理解正则表达式方面确实存在问题。 我想要一个正则表达式条件来检查字符串是否以数字开头。 我怎样才能在 PHP 中做到这一点?
提前致谢
使用preg_match()
<?php $string = "42foobar"; if (preg_match("/^\d/", $string)) { echo "string match was found."; } else { echo "string match was not found."; } ?>
^
\d