$str = ' People's Republic of China 123456789ABCDEFG ';
Echo Preg_match ("/^[\u4e00-\u9fa5_a-za-z0-9]{3,15}$", $strName);
Run the code above to see what prompts?
Warning:preg_match (): compilation Failed:pcre does not support \l, \l, \ n, \p, \p, \u, \u, or \x at offset 3 in F:\wwwro Ot\php\test.php on line 2
Originally, the following Perl escape sequences are not supported in PHP regular expressions: \l, \l, \ n, \p, \p, \u, \u, or \x
In UTF-8 mode, "\x{...}" is allowed, and the content in curly braces is a string that represents a hexadecimal number. The original hexadecimal escape sequence, \xhh, matches a double-byte UTF-8 character if its value is greater than 127.
So, can solve Preg_match ("/^[\x80-\xff_a-za-z0-9]{3,15}$", $strName);
Copy Code code as follows:
<?php
$shouji = "haha haha";
if (!preg_match ("/^[\x80-\xff]{6,30}$/", $shouji)) {
echo "NoNoNo";
}
else {
echo "Yesyesyes";
}
?>