62,244
社区成员




//代码写是比较好写,要直接用在那个组件上还真不知道怎么弄!
List<string> list = new List<string> { "Abc/123.html", "Abc/43.html", "Abc/989898.html", "Abc/abc454.html" };
foreach (string s in list)
{
string result = Regex.Replace(s, @"(?<=Abc/)([^\.]+)(?=\.html)", m =>
{
string str = m.Value.Length >= 4 ? m.Value.Substring(m.Value.Length - 4) : m.Value.PadLeft(4, '0');
return str + "/" + m.Value;
});
Console.WriteLine(result);
}
Console.ReadLine();
/*
Abc/0123/123.html
Abc/0043/43.html
Abc/9898/989898.html
Abc/c454/abc454.html
*/