Sample Code sharing of the HTML tag replacement function using JavaScript Regular Expressions (figure)

Source: Internet
Author: User
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  
   
   
   
   
   
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.