Regex help needed

Soldato
Joined
25 Mar 2004
Posts
2,885
Location
Iwade, Kent
Hi Guys,

I currently enforce some validation on my website for when a client sends an rDNS request into my system which is as follows:

$validate = "/^([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-]+)([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-]+)*\.([a-zA-Z]{2,6})$/";

I believe this forces something1.something2.something3

something1/2 can be anything where as something3 is limited to text and dots only (for the TLD) if I recall correctly.

The issue is, despite not being proper formatting, people often want to submit something.tld which our system currently blocks.

Can anyone suggest a correct syntex that will allow for:

something.tld
something.something.tld
something.something.something.tld

ETC?

Thanks!
 
Back
Top Bottom