Forum Moderators: open
Does anyone know if "replace" won't allow regular expressions? And if not, what's the best method to get this done?
I fear that my only alternative is to turn "img src=" into "a" to make it an a-tag so that it won't display for now ... I would like to rid of the tag all together, but ...
I've been googling for hours and found no solutions ...
-- Zak
<% @Language="VBScript" %>
<% Option Explicit %>
<%
Dim htmlOutput, outString
Dim tknStart, tknEnd, htmlSrc
If(Request.Form("btnSubmit") = "submit") Then
htmlOutput = StripBetweenTokens(Request.Form("tknStart"), Request.Form("tknEnd"), Request.Form("htmlSrc"))
End If
%>
<%
Function StripBetweenTokens(startToken, endToken, sourceString)
Dim sStart, sEnd
sStart = 0
sEnd = 0
sourceString = Replace(sourceString, """", "")
sStart = InStr(1, sourceString, startToken)
while(sStart > 0)
If(sStart > 0) Then
sEnd = InStr(sStart, sourceString, endToken)
If(sEnd > sStart) Then
sourceString = Replace(sourceString, Mid(sourceString, sStart, sEnd - sStart + Len(endToken)), "[REMOVED]")
else
StripBetweenTokens = "End Tag not found.. exiting"
Exit Function
End If
End If
sStart = InStr(1, sourceString, startToken)
wend
outString = sourceString
StripBetweenTokens = outString
End Function
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>RegexTest</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name=ProgId content=VisualStudio.HTML>
<meta name=Originator content="Microsoft Visual Studio .NET 7.1">
</head>
<body>
<form action="RegexTest.asp" id="RegexTest" name="RegexTest" method="post">
Start Token:<input id="tknStart" size="10" name="tknStart" type="text" value="<% = Request.Form("tknStart") %>"><br>
End Token:<input id="tknEnd" name="tknEnd" size="10" type="text" value="<% = Request.Form("tknEnd") %>"><br>
Search Text:<input id="htmlSrc" name="htmlSrc" size="50" type="text" value="<% = Request.Form("htmlSrc") %>"><br>
<input id="btnSubmit" name="btnSubmit" type="submit" value="submit">
</form>
<% = htmlOutput %>
</body>
</html>