SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Mar 2007
    Location
    United Kingdom
    Posts
    83
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Validating domain names - allowing .co.uk, etc.

    I searched the forum for posts about validating domain names and found a suggestion of:
    PHP Code:
    preg_match('/^([a-z0-9][a-z0-9\-]*[a-z0-9]\.)+[a-z]{2,6}$/i'$domain$matches); 
    Would that permit suffixes like .co.uk, .org.uk, etc? It looks like it might only allow .com, .net, etc.

    I need to allow domain names with two-part suffixes, since most of my site's visitors will likely be using them, and also allow them to include the www. prefix but not http:// . What do I need to change in the above example?

  2. #2
    @php.net Salathe's Avatar
    Join Date
    Dec 2004
    Location
    Edinburgh
    Posts
    1,397
    Mentioned
    65 Post(s)
    Tagged
    0 Thread(s)
    Those suffixes will be 'permitted' with that regular expression, as would things like this.is.not.valid.
    Salathe
    Software Developer and PHP Manual Author.

  3. #3
    SitePoint Enthusiast
    Join Date
    Mar 2007
    Location
    United Kingdom
    Posts
    83
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OK. Thanks.


Bookmarks

Posting Permissions

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