The regular expression is used to extract a Chinese character from a Chinese character string. & lt ;? Phpheader (Content-type: & nbsp; texthtml; & nbsp; charsetgb2312); & nbsp; $ regex & nbsp; large (xhh {1}); & nbsp; & nbsp; how to write here? I don't know how to use regular expressions. I hope you can help me solve this problem. thank you $ str & regular expressions for retrieving a certain Chinese character from a Chinese character string.
Header ("Content-type: text/html; charset = gb2312 ");
$ Regex = '/large (\ xhh {1}) good/'; // How to write here? I don't know regular expressions. I hope you can help me solve this problem. thank you.
$ Str = 'Hello all ';
$ Matches = array ();
If (preg_match ($ regex, $ str, $ matches )){
Var_dump ($ matches );
}
?>
I want to extract the word "home"
------ Solution --------------------
Reference:
Garbled characters. $ Str = 'A hello everyone '; $ regex ='/(.*?) Good /';
Header ("Content-type: text/html; charset = gb2312 ");
$ Regex = '/large (.*?) Good /';
$ Str = 'Hello all ';
$ 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) ""}
}