The code is as follows |
Copy Code |
function HTMLEncode (text) { Return Text.replace (/&/g, ' & '). Replace (/"/g, ' " '). Replace (/</g, ' < '). Replace (/>/g, ' > '); } function HtmlDecode (text) { Return Text.replace (/&/g, ' & '). Replace (/"/g, ' "). Replace (/</g, ' < '). Replace (/& gt;/g, ' > '); } |
' Method two
The code is as follows |
Copy Code |
function nohtml (str) Dim re Set Re=new regexp Re.ignorecase =true Re.global=true Re.pattern= "< (. [ ^>]*) > " Str=re.replace (str, "") Nohtml=str Set re=nothing End Function |
' Filter the HTML tag side method three
The code is as follows |
Copy Code |
function filterhtml (strtofilter) Dim objregexp, Match, Matches Set objregexp = new RegExp Objregexp.ignorecase = True Objregexp.global = True ' Take the closed <> Objregexp.pattern = "<.+?>" ' to match Set matches = Objregexp.execute (Strtofilter) ' Iterate through the matching set and replace the matching item For the match in matches Strtofilter=replace (Strtofilter,match.value, "") Next Filterhtml=strtofilter Set objregexp = Nothing End Function ' Call Str=filterhtml (str) |
' Filter HTML tags method four
The code is as follows |
Copy Code |
function nohtml (str) Dim re Set Re=new regexp Re.ignorecase =true Re.global=true Re.pattern= "(<.[ ^<]*>) " Str=re.replace (str, "") Re.pattern= "(</[^<]*>)" Str=re.replace (str, "") Nohtml=str Set re=nothing End Function |