在子字符串中查找相同的字符串并在前面加上一个分割符 比如一个字符串“<label id='label1'><label id='label1'><label id='label1'><label id='label1'><label id='label1'>”需要在每个label前增加一个分隔符‘|’要求用asp.net实现谢谢! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 public string encodeString="<label id='label1'> <label id='label1'> <label id='label1'> <label id='label1'> <label id='label1'>";public static string HtmlEncode(encodeString){ encodeString = encodeString.Replace("<", "|<"); return encodeString;} public string HtmlEncode() { StrHtml=" <label id='label1'> <label id='label1'> <label id='label1'> <label id='label1'> <label id='label1'>"; StrHtml= StrHtml.Replace(">", ">|"); 做替换把> 替换为>|如果需要的话! 你还可以把最后1个|移除掉StrHtml = StrHtml.substring(0,StrHtml.length-1)return StrHtml; } string value="<label id='label1'> <label id='label1'> <label id='label1'> <label id='label1'> <label id='label1'>"; int groupcount = System.Text.RegularExpressions.Regex.Matches(value, @"<label id='label1'>").Count; string tempValue=value; for (int j = 0; j < groupcount; j++) { int i = tempValue.LastIndexOf("<label id='label1'>"); tempValue = value.Substring(0, i); if (i > 0) { value=value.Insert(i, "|"); } } Response.Write(value); public string HtmlEncode() { StrHtml=" <label id='label1'> <label id='label1'> <label id='label1'> <label id='label1'> <label id='label1'>"; StrHtml= StrHtml.Replace(">", ">|"); StrHtml = StrHtml.TrimEnd("|");return StrHtml; } 菜鸟讨教!! 关于在线Word编辑的。求指点。 SqlDataSource控件怎么获取不到存储过程输出参数的值 (大家帮忙)ASP.NET中动态改变服务控件的位置问题 如何将string类型转换为date类型 怎么在客户端弹出设置打印机的对话框阿,急,在线等啊,摆脱各位兄弟了阿。 如何组建WEB站点在internet上测试WEB程序? SqlConnection成员如何在自定义类中实现序列化? ajax值的保存问题 IIS网站发布 统计代码是如何判断网站来路的 网页上显示字符的问题!
public static string HtmlEncode(encodeString)
{
encodeString = encodeString.Replace("<", "|<");
return encodeString;
}
public string HtmlEncode()
{
StrHtml=" <label id='label1'> <label id='label1'> <label id='label1'> <label id='label1'> <label id='label1'>";
StrHtml= StrHtml.Replace(">", ">|"); 做替换把> 替换为>|
如果需要的话! 你还可以把最后1个|移除掉
StrHtml = StrHtml.substring(0,StrHtml.length-1)
return StrHtml;
}
string value="<label id='label1'> <label id='label1'> <label id='label1'> <label id='label1'> <label id='label1'>";
int groupcount = System.Text.RegularExpressions.Regex.Matches(value, @"<label id='label1'>").Count;
string tempValue=value;
for (int j = 0; j < groupcount; j++)
{
int i = tempValue.LastIndexOf("<label id='label1'>");
tempValue = value.Substring(0, i);
if (i > 0)
{
value=value.Insert(i, "|");
}
}
Response.Write(value);
{
StrHtml=" <label id='label1'> <label id='label1'> <label id='label1'> <label id='label1'> <label id='label1'>";
StrHtml= StrHtml.Replace(">", ">|");
StrHtml = StrHtml.TrimEnd("|");
return StrHtml;
}