Extract plain text from html rich text

In fact, extract plain text from a very simple html rich text, rich text basically use html tags to text plus a variety of styles.

So just to rich text string "<.....>" tag removed, you can get plain text. We can use regular expressions to match all html tags, and replaced with a null character, as follows:

// html rich text labels removed, leaving a plain text
function getSimpleText (html) {
var = new new RE1 the RegExp ( "<+.?>", "g"); // html tags matching a regular expression, "g" a plurality of content matching the search matching
var msg = html.replace (re1, ' '); // replaced with a null character performs
return MSG;
}

 

java:

str = str.replaceAll("<.+?>", "");

------------------------------------

Original Address:

https://blog.csdn.net/fengxi__/article/details/79297773

Guess you like

Origin www.cnblogs.com/commissar-Xia/p/11330168.html