Date: 02-16-2022
Return to Index
created by gbSnippets
'Compilable Example: (Jose Includes)
#Compile Exe "mytest.exe"
#Debug Error On
#Debug Display On
#Include "Win32API.inc"
Function PBMain() As Long
Local HTML$
HTML$ = "this is a url <a href=""http://www.garybeene.com/myimage.gif"">This Image</a> and this URL <a href=""http://www.myplace.com/image.jpg"">ME!</a>"
? SimplifyLinks(HTML$)
End Function
Function SimplifyLinks(HTML$) As String
'for image URLs
'replace <a href="http://www.garybeene.com/image.gif">My Image</a>
'with
'this http://www.garybeene.com/image.gif My Image
Local ImageURL$, temp$, sHTML$, iPosA, iPosB As Long
sHTML$ = LCase$(HTML$)
iPosA = InStr(sHTML$,"<a href=")
While iPosA
iPosB = InStr(iPosA,sHTML$,">")
ImageURL$ = Mid$(HTML$, iPosA To iPosB)
sImageURL$ = LCase$(ImageURL$)
If InStr(sImageURL$,".gif") Or InStr(sImageURL$,".bmp") Or InStr(sImageURL$,".jpg") Or InStr(sImageURL$,".png") Then
Replace ImageURL$ With Mid$(ImageURL$, 10 To Len(ImageURL$)-2) + $Spc In HTML$
End If
sHTML$ = LCase$(HTML$)
iPosA = InStr(iPosB, sHTML$, "<a href=")
Wend
Function = HTML$
End Function
http://www.garybeene.com/sw/gbsnippets.htm