/** * Gets the path to the first picture in the HTML string * @param htmlcontent * @return */public static string getimgfromhtml (String htmlcontent) {if (HTMLC Ontent!=null) {String regex_img = "]*?> "; Pattern p_image = Pattern.compile (regex_img,pattern.case_insensitive); Matcher m_image = P_image.matcher (htmlcontent); if (M_image.find ()) { String img = m_image.group (0); Matcher m = Pattern.compile ("src\\s*=\\s*\"? *?) (\ "|>|\\s+)"). Matcher (IMG); if (M.find ()) { if (m.group (0)!=null) { return M.group (0). substring (5, m.group (0). Length ()-1); } } } return "";} /** * Get text content in HTML string (remove tag) * @param htmlcontent * @return */public static string getcontentfromhtml (string htmlcontent) {i F (htmlcontent!=null) {return Htmlcontent.replaceall ("<\\/?. +?> "," ");} Return "";}
Get the path to the first picture in the HTML string and get the text content in the HTML string (remove the label)