正则从汉字字符串中取某一个汉字 正则php 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 header("Content-type: text/html; charset=utf-8");$regex = '/大(.*?)好啊/';$str = '大家好啊';$matches = array(); if(preg_match($regex, $str, $matches)){ var_dump($matches);//array(2) { [0]=> string(12) "大家好啊" [1]=> string(3) "家" }} 如果我str里面还有字母,得用gb2312格式的该如何去写? 有什么区别吗?$regex = '/大(.*?)好啊/';$str = '大家好啊';$matches = array(); if(preg_match($regex, $str, $matches)){ var_dump($matches);}array(2) { [0]=> string(8) "大家好啊" [1]=> string(2) "家" } 会乱码。$str = 'a大家好啊';$regex = '/a大(.*?)好啊/'; header("Content-type: text/html; charset=gb2312"); $regex = '/大(.*?)好啊/';$str = '大家好啊';$str= mb_convert_encoding($str,'gb2312','UTF-8');$regex = mb_convert_encoding($regex,'gb2312','UTF-8');;$matches = array(); if(preg_match($regex, $str, $matches)){ var_dump($matches);//array(2) { [0]=> string(12) "大家好啊" [1]=> string(3) "家" }} 怎么可能?$regex = '/a大(.*?)好啊/';$str = 'a大家好啊';$matches = array(); if(preg_match($regex, $str, $matches)){ var_dump($matches);}array(2) { [0]=> string(9) "a大家好啊" [1]=> string(2) "家" } 循环嵌套问题。好像不难啊,我都搞晕了。 appserv中如何配置php.ini发送邮件 str_replace好像有bug 100分求个sql语句 怎么引用 类文件里面的函数 mysql_ pconnect和mysql_connect 有什么区别呢 请问这样的分类是怎么实现的? 发现一个问题请大家讨论。。。 哪位有关于讲“正则表达式”的书或文章?就是 /<(.*)>.*<\/\1>/ 表示什么意思? PHPUnit如何mock函数内部实例化的对象 PHP数组问题,取出多维数组前面的 调用数据库并循环
$regex = '/大(.*?)好啊/';
$str = '大家好啊';
$matches = array();
if(preg_match($regex, $str, $matches)){
var_dump($matches);
//array(2) { [0]=> string(12) "大家好啊" [1]=> string(3) "家" }
}
$str = '大家好啊';
$matches = array();
if(preg_match($regex, $str, $matches)){
var_dump($matches);
}array(2) { [0]=> string(8) "大家好啊" [1]=> string(2) "家" }
header("Content-type: text/html; charset=gb2312");
$regex = '/大(.*?)好啊/';
$str = '大家好啊';
$str= mb_convert_encoding($str,'gb2312','UTF-8');
$regex = mb_convert_encoding($regex,'gb2312','UTF-8');;
$matches = array();
if(preg_match($regex, $str, $matches)){
var_dump($matches);
//array(2) { [0]=> string(12) "大家好啊" [1]=> string(3) "家" }
}
$str = 'a大家好啊';
$matches = array();
if(preg_match($regex, $str, $matches)){
var_dump($matches);
}array(2) { [0]=> string(9) "a大家好啊" [1]=> string(2) "家" }