I want to validate a domain .The expression must only be in the format .
anywordwithoutspace.any
Here's my code
<?php
function validatereg($str1) {
//validate domain
if(preg_match('/^([a-z0-9])*(\.([a-z0-9])([-a-z0-9_-])?([a-z0-9])+)+$/i', $str1) {
//valid domain
}
else {
//not a valid domain
}
}
?>
I am not sure if its correct. Also please take note that after the period(which was 'any') can be any letter of maximum 4 letters.
Thanks in advance.