tags:

views:

10

answers:

1

In php we use the following code to block the url link passing via text boxes or textarea on form submit(For avoid bad link

passing from contact us form ).Is there any methode like this in classic asp using vb.

if($_POST['Register'])
{
    $username=$_POST['username'];
    if (preg_match('~(?:[a-z0-9+.-]+://)?(?:\w+\.)+\w{2,6}\S*~i', $username))
    {
         die('Access Denied Avoid Link');

    }
}

I use the following code in asp but shows error

<%@Language="VBScript%">
<%
Option Explicit

Dim Address 
Address = Request("Address") 

if(!preg_match("/^[a-zA-Z]+[:\/\/]+[A-Za-z0-9\-_]+\\.+[A-Za-z0-9\.\/%&=\?\-_]+$/i",& Address&))
{
Echo"Access Denied Avoid Link.";
Response.End
'Exit();
}
%>
A: 

You'll need to use the RegExp object, a simple example being

Dim re
Set re = New RegExp

re.Pattern = "^Hello.*" ' Replace with your regexp pattern
re.IgnoreCase = True

result = re.Test("Hello world") ' Returns boolean
If result Then
   ' Found!
Else
   ' Not found :-(
End If
Set re = Nothing

Regular Expression grammar in VBScript is likely to be a little different to PHP, so you may need to translate your regular expression slightly. See http://msdn.microsoft.com/en-us/library/ms974570.aspx for more details on Microsoft's RegExp class.

Chris J