//请修改变量p的正则表达式,使他能够匹配BBC
$p = '/bbc/i';
$str = "BBC是英国的一个电视台";
if (preg_match($p, $str)) {
echo '匹配成功';
}
$p = '/bbc/i';
$str = "BBC是英国的一个电视台";
if (preg_match($p, $str)) {
echo '匹配成功';
}
2017-10-13
$p = '/苹果/';
$str = "我喜欢吃苹果";
if (preg_match($p, $str)) {
echo '匹配成功';
}
$str = "我喜欢吃苹果";
if (preg_match($p, $str)) {
echo '匹配成功';
}
2017-10-13
简单暴力
$subject = "my email is spark@imooc.com";
//在这里补充代码,实现正则匹配,并输出邮箱地址
$pattern = '/\w*@\w*.\w*/';
preg_match($pattern,$subject,$matches);
echo($matches[0]);
$subject = "my email is spark@imooc.com";
//在这里补充代码,实现正则匹配,并输出邮箱地址
$pattern = '/\w*@\w*.\w*/';
preg_match($pattern,$subject,$matches);
echo($matches[0]);
2017-09-27
$subject = "abcedf";
$pattern = '/a(.*?)d/';
preg_match($pattern,$subject,$matches);
print_r($matches); // 结果为: Array([0]=>abcd [1]=>bce); //谢谢
$pattern = '/a(.*?)d/';
preg_match($pattern,$subject,$matches);
print_r($matches); // 结果为: Array([0]=>abcd [1]=>bce); //谢谢
2017-09-27