Obtain the address of the first image from a text clip.
Refer to the various regular expressions on the Internet and finally debug them.
<%
'Str = "<a href =" "post. php? Action = newthread & amp; fid = 2 & amp; extra = page % 3D1 ""> </a> <br/> Str = "
Response. write (GetImgSrc (str ))
Function GetImgSrc (str) 'gets the img Tag content
Dim tmp
Set objRegExp = New Regexp
ObjRegExp. IgnoreCase = true' case insensitive
ObjRegExp. Global = false' full-text search! Key!
ObjRegExp. Pattern = "] *) (. *?)> "
Set Matches = objRegExp. Execute (str)
For Each Match in Matches
Tmp = tmp & Match. Value
Next
GetImgSrc = getimgs (tmp)
End function
Function getimgs (str )'
Set objRegExp1 = New Regexp
Objregexp1.ignorecase = true' case insensitive
Objregexp1.global = true' full-text search
Objregexp1.pattern = "src =. + [(GIF | JPG | PNG)] +" 'expression
Set Mm = objregexp1.execute (STR)
For each mattings in mm
Imgsrc = match1.value
'There may be characters that cannot be filtered. Make sure that
Imgsrc = Replace (imgsrc ,"""","")
Imgsrc = Replace (imgsrc, "src = ","")
Imgsrc = Replace (imgsrc, "<","")
Imgsrc = replace (imgsrc, "> ","")
Imgsrc = replace (imgsrc, "img ","")
Imgsrc = replace (imgsrc ,"","")
Getimgs = getimgs & imgsrc concatenate the addresses in the string for backup.
Next
End function
%>
Output:
Images/200610261533.jpg