Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Objective-C中匹配CJK扩展B_Objective C_Regex_Unicode_Cjk - Fatal编程技术网

在Objective-C中匹配CJK扩展B

在Objective-C中匹配CJK扩展B,objective-c,regex,unicode,cjk,Objective C,Regex,Unicode,Cjk,我在尝试匹配NSString中的CJK扩展名B字符时遇到问题 CJK统一表意文字扩展名B是一个包含罕见字符的Unicode块 中文、日文、韩文和日文的历史CJK表意文字 越南人 字符的unicode块是:从U+20000到U+2A6DF 我正在使用正则表达式:[\\ud840-\\ud868][\\udc00-\\udfff]\\\ud869[\\udc00-\\udd6]来匹配CJK扩展名B字符 这是我的密码: NSString *searchedString = @"You may use

我在尝试匹配
NSString
中的CJK扩展名B字符时遇到问题

CJK统一表意文字扩展名B是一个包含罕见字符的Unicode块 中文、日文、韩文和日文的历史CJK表意文字 越南人

字符的unicode块是:从
U+20000
U+2A6DF
我正在使用正则表达式:
[\\ud840-\\ud868][\\udc00-\\udfff]\\\ud869[\\udc00-\\udd6]
来匹配CJK扩展名B字符

这是我的密码:

NSString *searchedString = @"You may use 
\Uxxxxxxxx
notation to match those Unicode characters outside the BMP plane.

Acc. to ICU regex docs:

\Uhhhhhhhh
Match the character with the hex value
hhhhhhhh
. Exactly eight hex digits must be provided, even though the largest Unicode code point is
\U0010ffff
.

So, use

NSString *pattern = @"[\\U00020000-\\U0002A6DF]+";

NSString*searchedString=@“您可以使用
\uxxxxx
符号来匹配BMP平面之外的Unicode字符

根据:

\uhhhhhh
将字符与十六进制值相匹配
hhhhhh
。即使最大的Unicode代码点是
\U0010ffff
,也必须提供八个十六进制数字

所以,使用


请参见

您的模式无效。非捕获组语法为
(?:…)
。另外,结尾的
g
代表一个字面字母
g
-是否有意?是否可能因为值位于
UTF-16
而不是
UTF-8
?@WiktorStribiżew抱歉,我不小心删除了(?:…当我格式化我的消息时部分。为了使它更简单,我更新了我的问题使用
\uxxxx
符号怎么样?试试
NSString*pattern=@“[\\U00020000-\\U0002A6DF]+”;
@WiktorStribiż非常感谢,它很有效!