1. Replace HTML tags
Copy Code code as follows:
ReplaceAll ("\\&[a-za-z]{0,9};", "" "). ReplaceAll (" <[^>]*> "," \n\t ")
The source code is as follows:
Copy Code code as follows:
/**
* String substitution
*/
Package Com.you.model;
/**
* HTML Tag replacement
* @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 ' > serial number </th> <th colspan= ' 2 ' > Dick </th><th> Zhao Liu </th></tr><table> ';
/**
* Replace HTML tags
*/
String subStr = Str.replaceall ("\\&[a-za-z]{0,9};", ""). ReplaceAll ("<[^>]*>", "\n\t");
/**
* Print the replaced string
*/
System.out.println ("Print the replaced string:" + subStr);
}
}
2, the results of the operation are as follows
Print the replaced string:
ordinal
Dick
Zhao Liu