asp常用的正则表达式实现字符串的替换
程序员文章站
2022-05-04 19:17:07
去除html标签正则<\/*[^<>]*>function losehtml(contentstr) ...
去除html标签正则<\/*[^<>]*>
function losehtml(contentstr)
dim clstemplosestr,regex
clstemplosestr = cstr(contentstr)
set regex = new regexp
regex.pattern = "<\/*[^<>]*>"
regex.ignorecase = true
regex.global = true
clstemplosestr = regex.replace(clstemplosestr,"")
set regex = nothing
losehtml = clstemplosestr
end function
去除网页中的class
function loseclasstag(contentstr)
dim clstemplosestr,regex
clstemplosestr = cstr(contentstr)
set regex = new regexp
regex.pattern = "(class=){1,}(""|\'){0,1}\s+(""|\'|>|\s){0,1}"
regex.ignorecase = true
regex.global = true
clstemplosestr = regex.replace(clstemplosestr,"")
loseclasstag = clstemplosestr
set regex = nothing
end function
function losescripttag(contentstr)
dim clstemplosestr,regex
clstemplosestr = cstr(contentstr)
set regex = new regexp
regex.pattern = "(<script){1,}[^<>]*>[^\0]*(<\/script>){1,}"
regex.ignorecase = true
regex.global = true
clstemplosestr = regex.replace(clstemplosestr,"")
losescripttag = clstemplosestr
set regex = nothing
end function
function loseiframetag(contentstr)
dim clstemplosestr,regex
clstemplosestr = cstr(contentstr)
set regex = new regexp
regex.pattern = "(<iframe){1,}[^<>]*>[^\0]*(<\/iframe>){1,}"
regex.ignorecase = true
regex.global = true
clstemplosestr = regex.replace(clstemplosestr,"")
loseiframetag = clstemplosestr
set regex = nothing
end function
function loseobjecttag(contentstr)
dim clstemplosestr,regex
clstemplosestr = cstr(contentstr)
set regex = new regexp
regex.pattern = "(<object){1,}[^<>]*>[^\0]*(<\/object>){1,}"
regex.ignorecase = true
regex.global = true
clstemplosestr = regex.replace(clstemplosestr,"")
loseobjecttag = clstemplosestr
set regex = nothing
end function
function losespantag(contentstr)
dim clstemplosestr,regex
clstemplosestr = cstr(contentstr)
set regex = new regexp
regex.pattern = "<(\/){0,1}span[^<>]*>"
regex.ignorecase = true
regex.global = true
clstemplosestr = regex.replace(clstemplosestr,"")
losespantag = clstemplosestr
set regex = nothing
end function
function losefonttag(contentstr)
dim clstemplosestr,regex
clstemplosestr = cstr(contentstr)
set regex = new regexp
regex.pattern = "<(\/){0,1}font[^<>]*>"
regex.ignorecase = true
regex.global = true
clstemplosestr = regex.replace(clstemplosestr,"")
losefonttag = clstemplosestr
set regex = nothing
end function
function loseatag(contentstr)
dim clstemplosestr,regex
clstemplosestr = cstr(contentstr)
set regex = new regexp
regex.pattern = "<(\/){0,1}a[^<>]*>"
regex.ignorecase = true
regex.global = true
clstemplosestr = regex.replace(clstemplosestr,"")
loseatag = clstemplosestr
set regex = nothing
end function
function losedivtag(contentstr)
dim clstemplosestr,regex
clstemplosestr = cstr(contentstr)
set regex = new regexp
regex.pattern = "<(\/){0,1}div[^<>]*>"
regex.ignorecase = true
regex.global = true
clstemplosestr = regex.replace(clstemplosestr,"")
losedivtag = clstemplosestr
set regex = nothing
end function
function losestyletag(contentstr)
dim clstemplosestr,regex
clstemplosestr = cstr(contentstr)
set regex = new regexp
regex.pattern = "(<style){1,}[^<>]*>[^\0]*(<\/style>){1,}"
regex.ignorecase = true
regex.global = true
clstemplosestr = regex.replace(clstemplosestr,"")
losestyletag = clstemplosestr
set regex = nothing
end function
function losenotetag(contentstr)
dim clstemplosestr,regex
clstemplosestr = cstr(contentstr)
set regex = new regexp
regex.pattern = "<!--\/*[^<>]*-->"
regex.ignorecase = true
regex.global = true
clstemplosestr = regex.replace(clstemplosestr,"")
losenotetag = clstemplosestr
set regex = nothing
end function
function losetabletag(contentstr)
dim clstemplosestr,regex
clstemplosestr = cstr(contentstr)
set regex = new regexp
regex.pattern = "<(\/){0,1}table[^<>]*>"
regex.ignorecase = true
regex.global = true
clstemplosestr = regex.replace(clstemplosestr,"")
losetabletag = clstemplosestr
set regex = nothing
end function
function losetdtag(contentstr)
dim clstemplosestr,regex
clstemplosestr = cstr(contentstr)
set regex = new regexp
regex.pattern = "<(\/){0,1}td[^<>]*>"
regex.ignorecase = true
regex.global = true
clstemplosestr = regex.replace(clstemplosestr,"")
losetdtag = clstemplosestr
set regex = nothing
end function
function losetrtag(contentstr)
dim clstemplosestr,regex
clstemplosestr = cstr(contentstr)
set regex = new regexp
regex.pattern = "<(\/){0,1}tr[^<>]*>"
regex.ignorecase = true
regex.global = true
clstemplosestr = regex.replace(clstemplosestr,"")
losetrtag = clstemplosestr
set regex = nothing
end function
function losehtml(contentstr)
dim clstemplosestr,regex
clstemplosestr = cstr(contentstr)
set regex = new regexp
regex.pattern = "<\/*[^<>]*>"
regex.ignorecase = true
regex.global = true
clstemplosestr = regex.replace(clstemplosestr,"")
set regex = nothing
losehtml = clstemplosestr
end function
去除网页中的class
function loseclasstag(contentstr)
dim clstemplosestr,regex
clstemplosestr = cstr(contentstr)
set regex = new regexp
regex.pattern = "(class=){1,}(""|\'){0,1}\s+(""|\'|>|\s){0,1}"
regex.ignorecase = true
regex.global = true
clstemplosestr = regex.replace(clstemplosestr,"")
loseclasstag = clstemplosestr
set regex = nothing
end function
function losescripttag(contentstr)
dim clstemplosestr,regex
clstemplosestr = cstr(contentstr)
set regex = new regexp
regex.pattern = "(<script){1,}[^<>]*>[^\0]*(<\/script>){1,}"
regex.ignorecase = true
regex.global = true
clstemplosestr = regex.replace(clstemplosestr,"")
losescripttag = clstemplosestr
set regex = nothing
end function
function loseiframetag(contentstr)
dim clstemplosestr,regex
clstemplosestr = cstr(contentstr)
set regex = new regexp
regex.pattern = "(<iframe){1,}[^<>]*>[^\0]*(<\/iframe>){1,}"
regex.ignorecase = true
regex.global = true
clstemplosestr = regex.replace(clstemplosestr,"")
loseiframetag = clstemplosestr
set regex = nothing
end function
function loseobjecttag(contentstr)
dim clstemplosestr,regex
clstemplosestr = cstr(contentstr)
set regex = new regexp
regex.pattern = "(<object){1,}[^<>]*>[^\0]*(<\/object>){1,}"
regex.ignorecase = true
regex.global = true
clstemplosestr = regex.replace(clstemplosestr,"")
loseobjecttag = clstemplosestr
set regex = nothing
end function
function losespantag(contentstr)
dim clstemplosestr,regex
clstemplosestr = cstr(contentstr)
set regex = new regexp
regex.pattern = "<(\/){0,1}span[^<>]*>"
regex.ignorecase = true
regex.global = true
clstemplosestr = regex.replace(clstemplosestr,"")
losespantag = clstemplosestr
set regex = nothing
end function
function losefonttag(contentstr)
dim clstemplosestr,regex
clstemplosestr = cstr(contentstr)
set regex = new regexp
regex.pattern = "<(\/){0,1}font[^<>]*>"
regex.ignorecase = true
regex.global = true
clstemplosestr = regex.replace(clstemplosestr,"")
losefonttag = clstemplosestr
set regex = nothing
end function
function loseatag(contentstr)
dim clstemplosestr,regex
clstemplosestr = cstr(contentstr)
set regex = new regexp
regex.pattern = "<(\/){0,1}a[^<>]*>"
regex.ignorecase = true
regex.global = true
clstemplosestr = regex.replace(clstemplosestr,"")
loseatag = clstemplosestr
set regex = nothing
end function
function losedivtag(contentstr)
dim clstemplosestr,regex
clstemplosestr = cstr(contentstr)
set regex = new regexp
regex.pattern = "<(\/){0,1}div[^<>]*>"
regex.ignorecase = true
regex.global = true
clstemplosestr = regex.replace(clstemplosestr,"")
losedivtag = clstemplosestr
set regex = nothing
end function
function losestyletag(contentstr)
dim clstemplosestr,regex
clstemplosestr = cstr(contentstr)
set regex = new regexp
regex.pattern = "(<style){1,}[^<>]*>[^\0]*(<\/style>){1,}"
regex.ignorecase = true
regex.global = true
clstemplosestr = regex.replace(clstemplosestr,"")
losestyletag = clstemplosestr
set regex = nothing
end function
function losenotetag(contentstr)
dim clstemplosestr,regex
clstemplosestr = cstr(contentstr)
set regex = new regexp
regex.pattern = "<!--\/*[^<>]*-->"
regex.ignorecase = true
regex.global = true
clstemplosestr = regex.replace(clstemplosestr,"")
losenotetag = clstemplosestr
set regex = nothing
end function
function losetabletag(contentstr)
dim clstemplosestr,regex
clstemplosestr = cstr(contentstr)
set regex = new regexp
regex.pattern = "<(\/){0,1}table[^<>]*>"
regex.ignorecase = true
regex.global = true
clstemplosestr = regex.replace(clstemplosestr,"")
losetabletag = clstemplosestr
set regex = nothing
end function
function losetdtag(contentstr)
dim clstemplosestr,regex
clstemplosestr = cstr(contentstr)
set regex = new regexp
regex.pattern = "<(\/){0,1}td[^<>]*>"
regex.ignorecase = true
regex.global = true
clstemplosestr = regex.replace(clstemplosestr,"")
losetdtag = clstemplosestr
set regex = nothing
end function
function losetrtag(contentstr)
dim clstemplosestr,regex
clstemplosestr = cstr(contentstr)
set regex = new regexp
regex.pattern = "<(\/){0,1}tr[^<>]*>"
regex.ignorecase = true
regex.global = true
clstemplosestr = regex.replace(clstemplosestr,"")
losetrtag = clstemplosestr
set regex = nothing
end function
上一篇: 创意灯饰--太美妙了