private static String stripHtml ( Content body ) { String rawString = body . toString ( ) ; // remove HTML tags rawString = rawString . replaceAll ( "\\<.*?>" , " " ) ; // consolidate multiple spaces between a word to a single space rawString = rawString . replaceAll ( "\\b\\s{2,}\\b" , " " ) ; // remove extra whitespaces return rawString . trim ( ) ; }
Given a Content node strips all html characters and return the result .