可用于键名匹配规则上。
using System.Text.RegularExpressions;
var arr = new[] { "EmailAddress", "BackgroundImage", "EmailAddress1", "EmailAddress21 1", "EmailAddress13_1", "C1OIncubation", "CIncubatio", "COIncubation", "COOIncubation", "BackgroundImage" };
foreach (var s in arr)
{
Console.WriteLine(Map(s));
}
string Map(string name)
{
string pattern = "([a-z]|[A-Z]+)([A-Z]|(\\d+))";
string replacement = "$1 $2";
string result = Regex.Replace(name, pattern, replacement);
return result;
}
// output:
// Email Address
// Background Image
// Email Address 1
// Email Address 21 1
// Email Address 13_1
// C 1O Incubation
// C Incubatio
// CO Incubation
// COO Incubation
// Background Image
标签:arr,string,C#,Incubation,空格,正则,result,Address,Email
From: https://www.cnblogs.com/fires/p/17790676.html