Go to the regular recommendation _ Regular expression of HTML code

Source: Internet
Author: User
Tags html tags regular expression tagname
Copy Code code as follows:

'==================================================
' Function name: scripthtml
' Function: Filter HTML tags
' Parameter: constr------The string to filter
'==================================================
Function scripthtml (Byval constr,tagname,ftype)
Dim Re
Set re=new REGEXP
Re.ignorecase =true
Re.global=true
Select Case FType
Case 1
Re.pattern= "<" & TagName & "([^>]) *>"
Constr=re.replace (Constr, "")
Case 2
Re.pattern= "<" & TagName & "([^>]) *>.*?</" & TagName & "([^>]) *>"
Constr=re.replace (Constr, "")
Case 3
Re.pattern= "<" & TagName & "([^>]) *>"
Constr=re.replace (Constr, "")
Re.pattern= "</" & TagName & "([^>]) *>"
Constr=re.replace (Constr, "")
End Select
Scripthtml=constr
Set re=nothing
End Function

1 content=scripthtml (content, "BR", 1) ' Remove all <br>html marks

2 content=scripthtml (Content, "a", 2) ' Remove the contents between all <a></a> and two tags
Like <a href=www.126.com>www.126.com</a> the whole piece.

3 content=scripthtml (content, "TD", 3) ' Remove <td> and </td>html mark
such as <td>-bureaucrat Caesar </td> take <td> </td> removed but the scholar-bureaucrat still retains

And so on, you filter all the other HTML tags, div objdect or something.
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.