This article mainly introduces the function of replacing HTML tags with JavaScript regular expressions, and analyzes in detail the implementation skills related to string replacement with javascript regular expressions in the form of a complete example, for more information, see # wiki/48.html "target =" _ blank "> use JavaScript regular expressions to replace HTML tags, detailed analysis of the implementation skills related to the string replacement operation using javascript regular expressions based on the complete instance form. For more information, see
This example describes how to replace HTML tags with JavaScript regular expressions. We will share this with you for your reference. The details are as follows:
1. Description
Obtain the HTML string (including tags), replace the HTML tag with a regular expression, and output the replaced string.
2. Implement JavaScript code
Function deleteTag () {var regx =/<[^>] *> | <\/[^>] *>/gm; var tagStr = $ ("# ul_li" ).html (); alert ("replace the previous string:" + tagStr); var result = tagStr. replace (regx, ""); alert ("replaced string:" + result );}
3. Running result
(1) During Initialization
4. Complete instance:
Replacing HTML tags with JavaScript