我需要提取出{}内的全部字符串,并加入List中。如:1-21-6,0-66-6,0-66-7
4 个解决方案
#1
@"(?<=\{).*?(?=\})"
#2
var str = "{1-21-6}/(({0-66-6}+{0-66-7})/2)";
var reg = new Regex("[0-9]*-[0-9]*-[0-9]*");
var mats = reg.Matches(str);
foreach (var item in mats)
{
Console.WriteLine(item);
}
#3
var str = "{1-21-6}/(({0-66-6}+{0-66-7})/2)";
var reg = new Regex("[0-9]*-[0-9]*-[0-9]*");
var mats = reg.Matches(str);
var list = new List<string>();
foreach (var item in mats)
{
list.Add(item.ToString());
}
#4
搞定,谢谢!
#1
@"(?<=\{).*?(?=\})"
#2
var str = "{1-21-6}/(({0-66-6}+{0-66-7})/2)";
var reg = new Regex("[0-9]*-[0-9]*-[0-9]*");
var mats = reg.Matches(str);
foreach (var item in mats)
{
Console.WriteLine(item);
}
#3
var str = "{1-21-6}/(({0-66-6}+{0-66-7})/2)";
var reg = new Regex("[0-9]*-[0-9]*-[0-9]*");
var mats = reg.Matches(str);
var list = new List<string>();
foreach (var item in mats)
{
list.Add(item.ToString());
}
#4
搞定,谢谢!