62,041
社区成员
发帖
与我相关
我的任务
分享
string str = "m^3t_4";
str = Regex.Replace(str, @"[_\^](\d+)", a =>
{
if (a.Value.Contains("^"))
return string.Format("<sup>{0}</sup>",a.Groups[1].Value);
else
return string.Format("<sub>{0}</sub>", a.Groups[1].Value);
});
//m<sup>3</sup>t<sub>4</sub>
string mm = " m^3t_4 ";
string nn=mm.Replace("^", "<sup></sup>").Replace("_", "<sub></sub>");