Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/tensorflow/5.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
在VB.NET中检测字符串中的汉字_Vb.net_Split_Cjk - Fatal编程技术网

在VB.NET中检测字符串中的汉字

在VB.NET中检测字符串中的汉字,vb.net,split,cjk,Vb.net,Split,Cjk,有没有一种方法可以检测如下构造的字符串中的汉字: dim test as string = "letters 中國的" 现在我只想给汉字添加子字符串。但是我的代码是数据库驱动的,所以我不能对它进行子串,因为长度总是不同的。那么,从我检测到汉字的那一刻起,有没有一种方法可以拆分字符串?我想你可以像下面的例子一样使用regexp,我已经多年没有使用VB.net编写代码了,所以语法可能不正确 Dim m As Match = Regex.Match(value, "[\u4e00-\u9fa5]+"

有没有一种方法可以检测如下构造的字符串中的汉字:

dim test as string = "letters 中國的"

现在我只想给汉字添加子字符串。但是我的代码是数据库驱动的,所以我不能对它进行子串,因为长度总是不同的。那么,从我检测到汉字的那一刻起,有没有一种方法可以拆分字符串?

我想你可以像下面的例子一样使用regexp,我已经多年没有使用VB.net编写代码了,所以语法可能不正确

Dim m As Match = Regex.Match(value, "[\u4e00-\u9fa5]+", 
                 RegexOptions.IgnoreCase)

' If successful, write the group.
If (m.Success) Then
    Dim key As String = m.Groups(1).Value

End If

检查每个字符的字节值是否在汉字范围内谢谢您的快速回复!你能给我举个例子吗?还是教程?