以下是字符串开头为start,字符串结尾为end,查找出现在他们中间所有的字符串
protected void Page_Load(object sender, EventArgs e)
{
var start = "@";
var end = "#";
var source = "@123# @456# @";
var reg = new System.Text.RegularExpressions.Regex("@(.+?)#");
var matchs = reg.Matches(source);
var result = new System.Collections.Generic.List <string>();
foreach (System.Text.RegularExpressions.Match m in matchs)
{
result.Add(m.Groups[1].Value);
}
}
输出结果:
123
456