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

PHP正则表达式的有关问题

WBOY
Release: 2016-06-13 12:01:28
Original
930 people have browsed it

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

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

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

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template