我正在尝试编写一个正则表达式来拆分以下字符串
"17. Entertainment costs,16. Employee morale, health, and welfare costs,3. Test"
进入
17. Entertainment costs
16. Employee morale, health, and welfare costs
3. Test
注意第二个字符串中的逗号。
我在努力
static void Main(string[] args) {
Regex regex = new Regex( ",[1-9]" );
string strSplit = "1.One,2.Test,one,two,three,3.Did it work?";
string[] aCategories = regex.Split( strSplit );
foreach (string strCat in aCategories) {
System.Console.WriteLine( strCat );
}
}
但是#号没有通过
1.One
.Test,one,two,three
.Did it work?
请您参考如下方法:
