diff --git a/Falcon.SugarApi.Test/StringExtendTest.cs b/Falcon.SugarApi.Test/StringExtendTest.cs
new file mode 100644
index 0000000..2613f83
--- /dev/null
+++ b/Falcon.SugarApi.Test/StringExtendTest.cs
@@ -0,0 +1,25 @@
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Falcon.SugarApi;
+
+namespace Falcon.SugarApi.Test
+{
+ [TestClass]
+ public class StringExtendTest
+ {
+ [TestMethod]
+ public void TestSplit() {
+ var str = $"a,b.c;d,e。f;g";
+ var strArr = str.SplitStr();
+ Assert.AreEqual(7, strArr.Length, "分割后长度应该为7");
+ str = null;
+ strArr = str.SplitStr();
+ Assert.IsNotNull(strArr);
+ Assert.AreEqual(0, strArr.Length);
+ }
+ }
+}
diff --git a/Falcon.SugarApi/StringExtend.cs b/Falcon.SugarApi/StringExtend.cs
index 3b56fdd..cc4cb27 100644
--- a/Falcon.SugarApi/StringExtend.cs
+++ b/Falcon.SugarApi/StringExtend.cs
@@ -1,9 +1,11 @@
-namespace Falcon.SugarApi
+using System;
+
+namespace Falcon.SugarApi
{
///
/// 字符串扩展
///
- internal static class StringExtend
+ public static class StringExtend
{
///
/// 字符串是否为空或null
@@ -17,5 +19,12 @@
/// 字符串
/// 与IsNullOrEmpty相反
public static bool IsNotNullOrEmpty(this string str) => !str.IsNullOrEmpty();
+
+ ///
+ /// 使用全角半角的逗号句号和分号分割字符串。
+ ///
+ /// 要分割的字符串
+ /// 字符串数组。当str为null时返回空数组
+ public static string[] SplitStr(this string? str) => str == null ? Array.Empty() : str.Split(new char[] { ',', ',', ';', ';', '.', '。' });
}
}