之前在extaspnet里使用grid的时候需要从动态列获取值.
Code
//str:需要提取字符串,inputname:控件名称
public string FindValueByName(string str, string inputname)
{
string reg = @"<input name=""(?<name>.*?)"" [\s\S]*?value=""(?<value>.*?)"" [\s\S]*?>";
Regex r = new Regex(reg, RegexOptions.None);
Match match = r.Match(str);
string aa = "";
while (match.Success)
{
string name = match.Groups["name"].ToString();
string value = match.Groups["value"].ToString();
if (name == inputname)
{
return value;
}
else
{
match = match.NextMatch();
}
}
return aa;
}