I have a public form on a website where users can enter information which is saved into a database. I have been getting a lot of submissions lately with links to porn sites. I would like to remove any links from the submissions before they are saved into the database and would like to use a regular expression to do that. I am using vbscript on an IIS server. I wouldn't mind removing any html tags from the submission - I tried the HTML 4.01 Elements submission on the regexlib.com website but it gave me a script error - so I thought I would try and just remove the anchor tags.
any help would be appreciated!!
Here is what I am trying but it removes everything:
'this is one of the strings that was submitted recently
strNatComplaint = "<a href="">test</a> Buy Viagra Buy Viagra: http://www.google.com/notebook/public/18056478031080516769/BDQPCQwoQqtfT27Qj <a href=http://www.google.com/notebook/public/18056478031080516769/BDQPCQwoQqtfT27Qj>Buy Viagra</a>"
strRegPattern = "(<[aA]\s).+(</[aA]>)"
blnIgnoreCase = true
strReplace = ""
strNatComplaint = ereg_replace(strNatComplaint,strRegPattern,strReplace,blnIgnoreCase)
'found this function on the web which looked like it would work
function ereg_replace(strOriginalString, strPattern, strReplacement, varIgnoreCase)
' Function replaces pattern with replacement
' varIgnoreCase must be TRUE (match is case insensitive) or FALSE (match is case sensitive)
dim objRegExp : set objRegExp = new RegExp
with objRegExp
.Pattern = strPattern
.IgnoreCase = varIgnoreCase
.Global = True
end with
ereg_replace = objRegExp.replace(strOriginalString, strReplacement)
set objRegExp = nothing
end function