C# 正则表达式提取字符串中括号里的值 :
分别提取不同括号中的值:
string getValue = Regex.Replace(str, @"(.*\()(.*)(\).*)", "$2"); //小括号()
Regex rgx = new Regex(@"(?i)(?<=\[)(.*)(?=\])"); //中括号[]
string tmp = rgx.Match(CvoName).Value; //中括号[]
string sheetData = Regex.Match(LinkData, @"\{(.*)\}", RegexOptions.Singleline).Groups[1].Value; //大括号{}
注意:本文归作者所有,未经作者允许,不得转载