简体   繁体   English

正则表达式 - PCRE 不支持 \\L、\\l、\\N、\\P、

[英]Regular expression - PCRE does not support \L, \l, \N, \P,

I need to use the following regular expression to validate some Asian characters我需要使用以下正则表达式来验证一些亚洲字符

 $regexp = "/^[\-'\u2e80-\u9fff\sa-zA-Z.]+$/"; // with warning

 $regexp = "/^[\-'\sa-zA-Z.]+$/";   // without warning

preg_match() [function.preg-match]: Compilation failed: PCRE does not support \\L, \\l, \\N, \\P, \\p, \\U, \\u, or \\X. preg_match() [function.preg-match]:编译失败:PCRE 不支持 \\L、\\l、\\N、\\P、\\p、\\U、\\u 或 \\X。

Do you know how to change the regular expression pattern so that I can validate the Asian characters from \⺀-\鿿你知道如何更改正则表达式模式,以便我可以验证\⺀-\鿿的亚洲字符\⺀-\鿿

I am using the latest XAMPP我正在使用最新的 XAMPP

Apache/2.2.14 (Win32) DAV/2 mod_ssl/2.2.14 OpenSSL/0.9.8l mod_autoindex_color PHP/5.3.1 mod_apreq2-20090110/2.7.1 mod_perl/2.0.4 Perl/v5.10.1

Thank you谢谢

PCRE does not support the \\uXXXX syntax. PCRE 不支持\\uXXXX语法。 Use \\x{XXXX} instead.使用\\x{XXXX}代替。 See here .这里

Your \⺀-\鿿 range is also equivalent to\⺀-\鿿范围也相当于

\\p{InCJK_Radicals_Supplement}\\p{InKangxi_Radicals}\\p{InIdeographic_Description_Characters}\\p{InCJK_Symbols_and_Punctuation}\\p{InHiragana}\\p{InKatakana}\\p{InBopomofo}\\p{InHangul_Compatibility_Jamo}\\p{InKanbun}\\p{InBopomofo_Extended}\\p{InKatakana_Phonetic_Extensions}\\p{InEnclosed_CJK_Letters_and_Months}\\p{InCJK_Compatibility}\\p{InCJK_Unified_Ideographs_Extension_A}\\p{InYijing_Hexagram_Symbols}\\p{InCJK_Unified_Ideographs}

Don't forget to add the u modifier ( /regex here/u ) if you're dealing with UTF-8.如果您正在处理 UTF-8,请不要忘记添加u修饰符( /regex here/u )。 If you're dealing with another multi-byte encoding, you must first convert it to UTF-8.如果您正在处理另一种多字节编码,则必须先将其转换为 UTF-8。

'/^[<\x{4e00}-\x{9fa5}>]+$/u';

Try this one.试试这个。 The regular expression you posted above is not supported by PHP,but Javascript does support that expression. PHP 不支持您上面发布的正则表达式,但 Javascript 支持该表达式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM