Detect chinese character in a string VB.NET

Is there a way to detect a Chinese character in a string which is build like this:

dim test as string = "letters 中國的"

Now I want to substring only the Chinese characters. But my code is database driven, so I can't substring it, because the length is always different. So is there a way I can split the string, from the moment I detect a Chinese character?

Answers


I think you can use regexp like in the following example, didn't test and I haven't code using VB.net for years So syntax may be not correct.

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

http://msdn.microsoft.com/en-us/library/twcw2f1c.aspx


Need Your Help

Three Inputs in a Row - Bootstrap 3

html css forms twitter-bootstrap

This is what I have now with Bootstrap 2. This is what Bootstrap 3 comes up with: And I have this code: <div class="row"> <div class="col-sm-4"><input type="text"

table creation fail in x-code for iPhone using sqlite

ios sqlite ios4 sqlite3

I used the following code for database creation in Xcode. It runs smoothly up to the NSFilemanager code, but after that it will terminating to else code that says status.text=@"failed to open/create