Jump to content

Regular Expression String to Block a UK Domain


Si

Recommended Posts

Does anyone know how I would get a validation string for a custom field I have, where I want to block domain names that have .co.uk, .org.uk or .me.uk

 

and which will only allow

 

domain names that end with, .com, .net, .biz, .org and .info ?

 

Thanks in advance.

Link to comment
Share on other sites

Well, you can either block .uk tld's, or you can ONLY allow the ones you listed. Doing both would be pointless.

 

To match any domain that doesnt end with .uk, you can use this:

 

/^[a-zA-Z0-9.-]+[^\.uk]$/

 

To match any domain ending in .com, .net, .biz, .org, or .info, you can use this.

 

/^[a-zA-Z0-9.-]+(\.com|\.net|\.biz|\.org|\.info)$/

 

Hope this helps.

Link to comment
Share on other sites

Well, you can either block .uk tld's, or you can ONLY allow the ones you listed. Doing both would be pointless.

 

To match any domain that doesnt end with .uk, you can use this:

 

/^[a-zA-Z0-9.-]+[^\.uk]$/

 

To match any domain ending in .com, .net, .biz, .org, or .info, you can use this.

 

/^[a-zA-Z0-9.-]+(\.com|\.net|\.biz|\.org|\.info)$/

 

Hope this helps.

 

EXCELLENT - Thank you so much. works a treat.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated