当前位置:网站首页>PHP Chinese regular

PHP Chinese regular

2022-06-25 19:07:00 Student Zhao who loves learning

Recently, I followed the tutorial PHP Regular is used in the project , The tutorial only gives English regular , Here I'll add the Chinese ones by the way .

When Chinese is not supported :
 Insert picture description here
It should be noted that :
PHP The following... Are not supported in regular expressions Perl Escape sequences :\L, \l, \N, \P, \p, \U, \u, or \X
stay UTF-8 In mode , Allowed “\x {…}”, The content in curly brackets is a string representing a hexadecimal number . The original hexadecimal escape sequence \xhh If its value is greater than 127 And then it matches a double byte UTF-8 character .
So you can do this :regex:/^[\x80-\xff_A-Za-z0-9-_]

The effect of the updated data is as follows :
 Insert picture description here  Insert picture description here

原网站

版权声明
本文为[Student Zhao who loves learning]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202190526002113.html