<%
function GetAttribute(byval strattribute,byval strtag)
	dim objRegEx,matches  
	set objRegEx = new RegExp '建立正则表达式
		objRegEx.pattern = lcase(strattribute)&"=""[0-9a-zA-Z]*"""   '查找内容
		objRegEx.ignorecase = true '忽略大小写
		objRegEx.global = true  '全局查找
	set matches = objRegEx.execute(strtag) '执行搜索
	if matches.count > 0 then   '如有匹配的则返回值, 不然返回空值
		GetAttribute = split(matches(0).value,"""")(1)
	else
		GetAttribute = ""
	end if
	set matches = nothing   '消毁对象
	set objRegEx = nothing
end function

function processcustomtag(byval scontent)
	dim objRegEx,match,matches
	set objRegEx = new RegExp
		objRegEx.pattern = "{DH654:[^<>]+?\/DH}"
		objRegEx.ignorecase = true
		objRegEx.global = true
	set matches = objRegEx.execute(scontent)
	for each match in matches
		scontent = replace(scontent,match.value,parsetag(match.value))
	next
	set matches = nothing
	set objRegEx = nothing
	processcustomtag = scontent
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

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 getkeywordstag(byval scontent) '获得百度的更多关键词 http://d.baidu.com/rs.php?q=%BB%FA%C6%B1&tn=63eu_pg
dim objRegEx,match,matches,keyword
    keyword="IT猫扑上网导航"
	set objRegEx = new RegExp
		objRegEx.pattern = "(\<li class=kwc><a target=_blank href=).+?(\>)(.*?)(\<\/a></li\>)"
		objRegEx.ignorecase = true
		objRegEx.global = true
	set matches = objRegEx.execute(scontent)
	for each match in matches
        keyword = keyword & ","	& objregEx.Replace(Match.Value,"$3") 	
	next
	set matches = nothing
	set objRegEx = nothing
	getkeywordstag = strvalue(keyword,255)
end function
Function getHTTPPage(url) 
  On Error Resume Next
  Dim http 
  SET http=Server.CreateObject("Microsoft.XMLHTTP") 
  Http.open "GET",url,False 
  Http.send() 
  IF(Http.readystate<>4)THEN
    Exit Function 
  END IF 
  getHTTPPage=BytesToBSTR(Http.responseBody,"GB2312")
  SET http=NOTHING
  IF(Err.number<>0)THEN
    Response.Write "获取文件内容出错,可能网络忙，稍后再试！" 
    Err.Clear
  END IF
End Function  
Function BytesToBstr(CodeBody,CodeSet)
  Dim objStream
  SET objStream = Server.CreateObject("adodb.stream")
  objStream.Type = 1
  objStream.Mode =3
  objStream.Open
  objStream.Write CodeBody
  objStream.Position = 0
  objStream.Type = 2
  objStream.Charset = CodeSet
  BytesToBstr = objStream.ReadText 
  objStream.Close
  SET objStream = NOTHING
End Function

function IsWebsiteTag(Str) '判断是否网址格式
	IsWebsiteTag = False
	Dim RegEx,Match
	Set RegEx = New RegExp
		RegEx.Pattern =  "((https?|ftp)\://((\[?(\d{1,3}\.){3}\d{1,3}\]?)|(([-a-zA-Z0-9]+\.)+[a-zA-Z]{2,4}))(\:\d+)?(/[-a-zA-Z0-9._?,'+&%$#=~\\]+)*/?)$"
		RegEx.IgnoreCase = True
	Set Match = RegEx.Execute(Str)
	If Match.Count Then IsWebsiteTag = True
end function

function getfilenametag(byval URL) '从网址中获得生成文件名
    dim filename:filename=LCase(FuckJP(URL))
	filename=Replace(filename,"\","/")    	
	filename=split(filename,"://")(1)
    if filename="" then filename="itmop.com"
    filename=split(filename,"/")(0)
    filename=Replace(filename,"www.","")
    filename=Replace(filename," ","")		
   'filename=Replace(filename,".","_")
	filename=Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(Replace(filename,"""",""),"?",""),"*",""),":",""),"|",""),"\",""),"/",""),">",""),"<","")
	getfilenametag = filename
end function


Function IsValidEmail(Str) '判断邮箱
	IsValidEmail = False
	Dim RegEx,Match
	Set RegEx = New RegExp
		RegEx.Pattern = "^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$"
		RegEx.IgnoreCase = True
	Set Match = RegEx.Execute(Str)
	If Match.Count Then IsValidEmail = True
End Function
Function IsValidEName(Str) '判断英文和数字 
	IsValidEName = False
	Dim RegEx,Match
	Set RegEx = New RegExp
		RegEx.Pattern = "/^[a-zA-Z]{1}[a-zA-Z0-9-_$#*()]{0,29}$/"
		RegEx.IgnoreCase = True
	Set Match = RegEx.Execute(Str)
	If Match.Count Then IsValidEName = True
End Function

'//函数：字符串查找
'    //参数：正则表达式,被替换字符串,替换字符串
'    //返回：Bool(True:找到)
    Public Function FindText(patrn,mStr)
	     on error resume next
        Dim regEx
        Set regEx = New RegExp
        regEx.Pattern = patrn
        regEx.IgnoreCase = True
        regEx.Global = True
        FindText = regEx.Test(mStr)
    End Function

%>