时间:2021-07-01 10:21:17 帮助过:83人阅读
header("Content-type: text/html; charset=gb2312");
$regex = '/大(\xhh{1})好啊/'; //这里该如何去写,我不会正则,希望大家能帮我解答一下,谢谢
$str = '大家好啊';
$matches = array();
if(preg_match($regex, $str, $matches)){
var_dump($matches);
}
?>
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) "家" }
}