From a string extracted Chinese, English, numbers
Chinese characters 30Margin Chinese characters 40HorizontalAlignment
Regular Expressions:
. 1 /// <Summary> 2 /// letters and numbers . 3 /// </ Summary> . 4 public const String The lettersAndNumbers = " [A-zA-Z0-9] + " ; . 5 . 6 /// <Summary> 7 /// Chinese characters . 8 /// </ Summary> . 9 public const String ChineseChars = " [\ u4E00- \ u9FA5] + " ; 10 . 11 /// <Summary> 12 is /// English characters 13 /// < / summary> 14 public const string EnglishChars = "[a-zA-Z]+";
Regex use:
1 string ChineseChars = "[\u4E00-\u9FA5]+"; 2 var match = Regex.Match("中文字符30Margin中文字符40HorizontalAlignment", ChineseChars, RegexOptions.IgnoreCase); 3 var result = $"Index:{match.Index},Length:{match.Length}\r\nResult:{match.Value}";
Note:
Regex returns only the first match
If you need to get all the matches regular correspondence, you can use Regex.Matches