110,536
社区成员
发帖
与我相关
我的任务
分享
Regex reg = new Regex("TV([0-9]+)");//或者new Regex("TW([0-9]+)")
Match match = reg.Match(txt);
if (match.Success)
{
【】间的内容= Convert.ToInt32(match.Groups[1].Value);}
static void Main(string[] args)
{
var txt ="IF(AND(【1】<=40,【2】>=0),\"OK\",\"High\")";
var d = new Dictionary<string,string>();
d.Add("【1】", "TV{0}");
d.Add("【2】", "TW{0}");
var n = 22;
Console.WriteLine(Regex.Replace(txt, @"【\d+】", m => string.Format(d[m.Value], n)));
}