110,538
社区成员
发帖
与我相关
我的任务
分享
void Main()
{
string html=@"<span name=""code"" width=""65px"" style=""background:#CCC;font-size:14px""> 8+4=?
";
foreach(Match m in Regex.Matches(html,@"(?is)<span[^>]*?>.*?(\d+[+\-x]\d+)"))
{
string temp=m.Groups[1].Value;
if(!string.IsNullOrEmpty(temp))
{
Console.WriteLine("{0} = {1}",temp,new DataTable().Compute(temp.Replace("x","*"),null));
}
}
//8+4 = 12
}
var regex = /\d+[+\-x]\d+/
var str = '<span name="code" width="65px" style="background:#CCC;font-size:14px"> 8+4 </span>';
str = str.replace(regex,function(w)
{
return eval(w.replace(/x/,"*"));
})
alert(str)
void Main()
{
string html=@"<span name=""code"" width=""65px"" style=""background:#CCC;font-size:14px""> 8x4=?
";
foreach(Match m in Regex.Matches(html,@"(?i)(?<=<span[^>]*?>\D+)\d+[+\-x]\d+(?=\=\?)"))
{
string temp=m.Value;
if(!string.IsNullOrEmpty(temp))
{
Console.WriteLine("{0} = {1}",temp,new DataTable().Compute(temp.Replace("x","*"),null));
}
}
//8x4 = 32
}