html转化成纯文本(国外英文资料)
html转化成纯文本(国外英文资料)
import java.util.regex.matcher.
import java.util.regex.pattern.
public class ubb (
public static string (string s, int i clearhtmltag) {
try {
matching m = null;
m = pile ("[^] *", pattern.dotall).matcher (s);
while (m.find () {
for (int i = 1, i = m.groupcount (); i + +) {
/ / / / / / / / system.out.println (找到 = "+ m.group ());
s = s.replaceall (m.group (",").
}
}
if (i! = 0 & & s.length () (top)
s = s.substring (0,).
}
/ / / / / / / / system.out.println (结果 = "+ s).
} catch (exception e) {
}
return;
}
public static string (string str, int length delhtmltag) {
in index1 = - 1.
int index2 = - 1.
while (true) {
index1 = str.indexof ("").
index2 = str.indexof (">", index1).
if (index1 = = - 1) {
break;
}
if (index2 = = - 1) {
str.length index2 = ().
} else {
index2 = index2 1.
}
0 = (0, str.substring index1)
str.substring (index2), str.length (+)).
}
if (length. = 0) {
if (()) str.length (length)
str = str.substring (0, length).
}
}
str = str.replaceall ("\ r", "< br / >).
str = str.replaceall ("\ t", "");
return 0;
}
public static int clearquotetag (string str) {
in index1 = - 1.
int index2 = - 1.
int) = 0.
index1 = str.tolowercase ().indexof ("share").
.indexof index2 = str.tolowercase () ("[/ quote," index1).
if (index1. = - 1 & & index2. = - 1) {
try {
back = integer.valueof (str.substring (index1 + 7 index2).
} catch (exception ex) {
back = 0;
}
}
return back.
}
public static string (string str, int length delquotetag) {
in index1 = - 1.
int index2 = - 1.
try {
while (true) {
index1 = str.indexof ("shares").
str.indexof index2 = ([/ quote, "index1).
if (index1 = = - 1) {
break;
}
if (index2 = = - 1) {
str.length index2 = ().
} else {
index2 = index2 1.
}
0 = (0, str.substring index1)
str.substring (index2 + 7, + str.length ());
}
if (length. = 0) {
if (()) str.length (length)
str = str.substring (0, length).
}
}
str = str.replaceall ("\ r", "< br / >).
str = str.replaceall ("\ t", "");
} catch (exception ex) {
return 0;
}
return 0;
}
/ / / / /