我想把一个文件里面的汉字全部取出来。
而汉字中间有空格(或" ")也要求可以。我目前的是“[\u4e00-\u9fa5]+”,但是这样的话,如果汉字中间有空格就会被分成几个了。
比如
<html>
<head>
<title>取 汉 字</title>
</head>
<body>
我要取 汉字
</body>
</html>我要的结果是两个字符串 ""取 汉 字,"我要取 汉字"
而汉字中间有空格(或" ")也要求可以。我目前的是“[\u4e00-\u9fa5]+”,但是这样的话,如果汉字中间有空格就会被分成几个了。
比如
<html>
<head>
<title>取 汉 字</title>
</head>
<body>
我要取 汉字
</body>
</html>我要的结果是两个字符串 ""取 汉 字,"我要取 汉字"
try {
ResultString = Regex.Match(SubjectString, "([[\\u4e00-\\u9fa5|\\s]( )?)*").Value;
} catch (ArgumentException ex) {
// Syntax error in the regular expression
}