js regular matching (remove html tags)

1. Get the link address on the web page:

string matchString = @"<a[^>]+href=\s*(?:'(?<href>^']+)'|""(?<href>[^""]+)""|(?<href>[^>\s]+))\s*[^>]*>";

2. Get the title of the page:

string matchString = @"<title>(?<title>.*)</title>";

3. Remove all html tags in the web page:

string temp = Regex.Replace(html, "<[^>]*>", ""); //html是一个要去除html标记的文档

4, string matchString = @"<title>([\S\s\t]*?)</title>";
5, js function to remove all html tags:

function delHtmlTag(str)
{
      return str.replace(/<[^>]+>/g,"");//去掉所有的html标记
}

6. Statistics word count

t = $('.remarktext').html().replace(/<[^>]+>/g,"").length;

Guess you like

Origin www.cnblogs.com/homehtml/p/12683753.html