// entity ref 처리
Pattern Eentity = Pattern.compile("&[^;]+;");
mat = Eentity.matcher(str);
str = mat.replaceAll("");
public static String removeHtmlEntities(String str) {
// Define regular expression to match HTML entities
String regex = "&(?:#[0-9]+|[a-zA-Z]+|#[xX][0-9a-fA-F]+);";
// Replace HTML entities with empty string
String result = str.replaceAll(regex, "");
return result;
}
String myString = "This is an example with "quotes" and <tags>.";
String result = removeHtmlEntities(myString);
System.out.println(result); // Output: "This is an example with quotes and tags."
'PROGRAMMING > JAVA' 카테고리의 다른 글
maven (0) | 2013.01.09 |
---|---|
이클립스 (Eclipse)에서 로컬 톰캣띄우고 한글 파라미터 깨질 때 (0) | 2012.11.11 |
[Java] mockito spy void method (0) | 2011.04.08 |
[java] 스프링 (0) | 2011.03.20 |
[java] Cannot cast from Object to long (0) | 2010.11.24 |