ews-java-api
ews-java-api copied to clipboard
how to get the text values of appointment.getBody() without HTML Tags?
String content = appointment.getBody().toString();
thie conent contain the html tags,but I want to get only the text of body.
how to get the text values of the body without HTML Tags?
Parse it...
String patternString = "(.*<body.*?>)(.*)(</body>.*)";
Pattern pattern = Pattern.compile(patternString, Pattern.CASE_INSENSITIVE);
String htmlStr = "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"><style type=\"text/css\" style=\"display:none\"><!-- p { margin-top: 0px; margin-bottom: 0px; }--></style></head><body dir=\"ltr\" style=\"font-size:12pt;color:#000000;background-color:#FFFFFF;font-family:Calibri,Arial,Helvetica,sans-serif;\"><p>Some notes<br></p></body></html>";
Matcher matcher = pattern.matcher(htmlStr);
String htmlContent = matcher.matches() ? matcher.group(2) : "";
// html content
System.out.println(htmlContent);
// stripped html content
System.out.println(htmlContent.replaceAll("<.*?>", ""));
you can also use some third party as jsoup
whether or not provide only the text of body without html tags in future for EWS API?
Lets have this as enhancement