Home  >  Article  >  Backend Development  >  PHP正则表达式的有关问题

PHP正则表达式的有关问题

WBOY
WBOYOriginal
2016-06-13 12:01:28857browse

PHP正则表达式的问题
我写了这么一行代码,想匹配一串数字:

preg_match('/\d*/, $line, $match);

但为什么结果是匹配了一个空串?
------解决方案--------------------
* 表示0个或多个规则字符
空串是0个数字,自然是能匹配到的
------解决方案--------------------
\d+

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn