110,534
社区成员
发帖
与我相关
我的任务
分享
<p>用户名称: <input type="text" name="Name" style="width: 300px" /></p>
<p>性别:
<input type="radio" name="sex" value="男"><br><input type="radio" name="sex" value="女" checked>女
<p>客户电话: <input type="text" name="CustomerTel" style="width: 300px" /></p>
<p>客户类型: <input type="radio" name="ctype" value="VIP" >VIP <br><input type="radio" name="ctype" value="钻石" checked>钻石 <input type="radio" name="ctype" value="黄金" >黄金</p>
.....
<p>客户地址: <input type="text" name="CustomerAddress" style="width: 500px" /></p>
........
public static string GetRegexInputradioValue(string html, string name)
{
try
{
string pattern = @"<input type=""radio""[\s\S]*?name=""(?<name>.*?)""[\s\S]*?value=""(?<value>.*?)""[\s\S]*?checked>";
if (Regex.IsMatch(html, pattern))
{
Match math = Regex.Match(html, pattern, RegexOptions.Singleline | RegexOptions.IgnoreCase);
while (math.Success)
{
if (name == math.Groups["name"].Value)
{
return math.Groups["value"].Value;
}
math = math.NextMatch();
}
}
return string.Empty;
}
catch (Exception ex)
{
return string.Empty;
}
}
//调用
GetRegexInputradioValue(html,"sex")
GetRegexInputradioValue(html,"ctype")