Results 1 to 2 of 2

Thread: regex to validate URL[solved]

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773

    regex to validate URL[solved]

    Hi.
    I found a few regex on the net to validate a url however it doesnt quite work for me.

    I want to make sure that the url is validate on this condition:

    optional 'www' beginning
    ends with a . (we do not care about if it ends in co.uk or com as in the future who knows what other domains will be available)

    any ideas?

    I also want to make sure that something like this is invalid:

    spaces in the url
    http://.xxxxxx

    that dot should not be there...invalid url


    the one I am currently using which appears to work reasonably is this one however it does have it's flaws.

    ^(http|ftp)://(www\.)?.+\.
    Last edited by Techno; May 25th, 2006 at 10:27 AM.

    MVP 2007-2010 any chance of a regain?
    Professional Software Developer and Infrastructure Engineer.

  2. #2

    Thread Starter
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773

    Re: regex to validate URL

    this one seems to work:

    ^http\://[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(/\S*)?$

    got it from:
    http://regexlib.com

    good site for regex!

    MVP 2007-2010 any chance of a regain?
    Professional Software Developer and Infrastructure Engineer.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width