添加项目文件。
This commit is contained in:
25
Szmedi.RevitToolkit.Approval/Extensions/Extension.cs
Normal file
25
Szmedi.RevitToolkit.Approval/Extensions/Extension.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Szmedi.RevitToolkit.Approval.Extensions
|
||||
{
|
||||
internal static class Extension
|
||||
{
|
||||
/// <summary>
|
||||
/// 提取字符串中所有中文字符
|
||||
/// </summary>
|
||||
public static string ExtractChinese(this string text)
|
||||
{
|
||||
if (string.IsNullOrEmpty(text)) return string.Empty;
|
||||
|
||||
// 先将非中文替换为空格,再将连续空格替换为单个空格,最后去除首尾空格
|
||||
var result = Regex.Replace(text, @"[^\u4e00-\u9fa5]", " ");
|
||||
result = Regex.Replace(result, @"\s+", " ").Trim();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user