' Collection of code snippets by Arne Vajhøj 
' (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
Function cvt(s)
    Set re = New RegExp
    re.Pattern = "(<img\s+src\s*=\s*"")([^""]*)(""\s*>)(?!</a>)"
    re.Global = True
    cvt = re.Replace(s, "<a href=""$2"">$1$2$3</a>")
End Function

WScript.Echo cvt("<img src=""/images/testimage.jpg"">")
WScript.Echo cvt("<a href=""/images/testimage.jpg""><img src=""/images/testimage.jpg""></a>")
WScript.Echo cvt("bla <img src=""/images/testimage.jpg""> bla")
WScript.Echo cvt("bla <a href=""/images/testimage.jpg""><img src=""/images/testimage.jpg""></a> bla")
