Dictionary<int, string> dic = new Dictionary<int, string>();
dic.Add(1, "AAA");
dic.Add(2, "BBB");
dic.Add(12, "CCC");
string a = ".12";
foreach (var temp in dic)
{
a = Regex.Replace(a, $"\\.{temp.Key}(?=[^\\d])", temp.Value);
}
如果是".12 "會替換
但是最后只是.12不會替換成CCC呢。
求怎么改
uj5u.com熱心網友回復:
說下你有什么資料,想做什么事,我不熟悉正則運算式,所以寫代碼也盡量避開使用這個,說出你的需求,給你個其他解決方法.轉載請註明出處,本文鏈接:https://www.uj5u.com/net/251062.html
標籤:C#
