您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

正则从汉字字符串中取某一个汉字解决方案

2024/3/27 14:52:04发布16次查看
正则从汉字字符串中取某一个汉字

我想取出“家”字
------解决方案--------------------
引用:会乱码。$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) 家 }
}
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product