Topic: Regex Expressions.

I am attempting to write a regex expression for my jquery validation. I am attempting to make it match up with what I have cleaning the same textarea in my PHP code. I am using this generator or similar to help me. http://www.jslab.dk/tools.regex.php When making my expression I want to prevent http:// and www. but in the php it's preventing link= and url= should I match those instead? Is that BB code or something? Thanks!

Here are the PHP rules I want to match.
if (preg_match("{link=}", $comment) || preg_match("{url=}", $comment) || preg_match("{http://}", $comment))
{
    header( "Location: $errorurl" );
    exit ;
}

Re: Regex Expressions.

Amazing!!!! I just coded my own custom validation rule with the regex s**t. But my question still stands. So I now have no http://, www. link=, url= allowed. Should I exclude the link=/url= or no?

Here is my I got lucky code....
$(document).ready(function(){
        $.validator.addMethod("nourl",
                    function(value, element) {
                         return !/http\:\/\/|www\.|link\=|url\=/.test(value);
                        },
                        "No URL's"
      );

Re: Regex Expressions.

Should I exclude the link=/url= or no?

I'd say yes -- it has appeared in my comment spam before. Really depends on your situation though... you could leave it out, wait a bit and see what sort of spam you are getting, and then add additional filters if necessary.

Re: Regex Expressions.

Thanks Ben! I kept them as you suggested, and added www. to my php. smile