1、替换html标签
replaceall("\\&[a-za-z]{0,9};", "").replaceall("<[^>]*>", "\n\t")
源码如下:
/**
* 字符串替换
*/
package com.you.model;
/**
* html标签替换
* @author yhd
* @version
*/
public class strreplace {
/**
* @param args
*/
public static void main(string[] args)
{
string str = " <table border='1' cellpadding='1' cellspacing='1'><tr><th rowspan='2'>序号</th><th colspan='2'>李四</th><th>赵六</th></tr><table>";
/**
* 替换html标签
*/
string substr = str.replaceall("\\&[a-za-z]{0,9};", "").replaceall("<[^>]*>", "\n\t");
/**
* 打印替换后的字符串
*/
system.out.println("打印替换后的字符串:" + substr);
}
}
2、运行结果如下
打印替换后的字符串:
序号
李四
赵六
您可能感兴趣的文章:
如您对本文有疑问或者有任何想说的,请 点击进行留言回复,万千网友为您解惑!
网友评论