kenzo123
2016-01-06 11:57
为什么这样不行
<?php
//请修改变量p的正则表达式,使他能够匹配str中的姓名
$p = '/\w+\s+\w+/';
$str = "name:steven jobs";
preg_match($p, $str, $match);
echo $match[1]; //结果为:steven jobs
这样却可以通过编译呢
<?php
//请修改变量p的正则表达式,使他能够匹配str中的姓名
$p = '/\w{6}\s{1}+\w{4}/';
$str = "name:steven jobs";
preg_match($p, $str, $match);
echo $match[0]; //结果为:steven jobs
同问这个问题,我也是搞不明白
<?php
$p='/\w+\s+\w+/';
$str="name:steven jobs";
preg_match($p,$str,$match);
echo $match[0];
此数组只有一个数,只有$match[0],没有$match[1].
PHP进阶篇
181960 学习 · 2668 问题
相似问题