. NET Regular expression: Scenario description
This is a netizen's question, request as follows:
Give a string, such as "China I loved You I love You", the program can achieve the difference between Chinese and English;
The identification result is as follows: Total four elements
I love you
I Love You
. NET regular Expression resolution code
This kind of problem, is born to the regular expression preparation, hehe.
String PTN = "[\u4e00-\u9fa5]+[a-za-z\\s]+";
System.Text.RegularExpressions.Regex reg = new System.Text.RegularExpressions.Regex (PTN);
String z = "China Chinese I love You I Loving You";
foreach (Match m in Reg.) Matches (z))
It's up there. NET regular expression to implement the code in English and Chinese, very concise!