When we use ckeditor or some other online text editors, there are a lot of labels in the content:
A journey of life, a journey of scenery, a journey of prosperity. Open the window of the soul, watching the time and the flowers bloom, watching the mountains are mountains, watching the water is the realm of life will be happy, the most beautiful life, it is the transparency and joy from the depths of the soul.
-- Question
Like in the afternoon of the snow, Ying Yi Jing, book a touch of feelings, see the snow falls into the deepest place of the red dust. Leave the world for now, empty your mind, and try to appreciate the beauty and purity. In the journey of life, there will be unexpected joys and sorrows, and the ground will be red and warm; a tree may bloom, and the snow may be like dust, and the helplessness of the world can be wiped out, it can also purify the soul.
Contains html tags such as images, paragraphs, and line breaks. to calculate the number of words, remove these tags. Use the following java Regular Expression Code:
/*** Delete the Html Tag ** @ param inputString * @ return */public static String htmlRemoveTag (String inputString) {if (inputString = null) return null; string htmlStr = inputString; // String textStr = ""; java. util. regex. pattern p_script; java. util. regex. matcher m_script; java. util. regex. pattern p_style; java. util. regex. matcher m_style; java. util. regex. pattern p_html; java. util. regex. matcher m_html; try {// Define the regular expression {or <script [^>] *?> [\ S \ S] *? <\\/ Script> String regEx_script = "<[\ s] *? Script [^>] *?> [\ S \ S] *? <[\ S] *? \/[\ S] *? Script [\ s] *?> "; // Define the regular expression of the style {or
] *?> [\ S \ S] *? <\\/ Style> String regEx_style = "<[\ s] *? Style [^>] *?> [\ S \ S] *? <[\ S] *? \/[\ S] *? Style [\ s] *?> "; String regEx_html =" <[^>] +> "; // defines the regular expression p_script = Pattern for HTML tags. compile (regEx_script, Pattern. CASE_INSENSITIVE); m_script = p_script.matcher (htmlStr); htmlStr = m_script.replaceAll (""); // filter the script tag p_style = Pattern. compile (regEx_style, Pattern. CASE_INSENSITIVE); m_style = p_style.matcher (htmlStr); htmlStr = m_style.replaceAll (""); // filter the style tag p_html = Pattern. compile (regEx_html, Pattern. CASE_INSENSITIVE); m_html = p_html.matcher (htmlStr); htmlStr = m_html.replaceAll (""); // filter html Tag textStr = htmlStr;} catch (Exception e) {e. printStackTrace ();} return textStr; // return a text string}