I need to validate domain name from text bunch of text string to handle the following:
www.dewalist.com
dewaxxxx.com
ng.dewalist.com
dewaster.com.au
test.co.uk
...
...
I can use FILTER_VALIDATE_URL however this only validates the full url: http://www.dewalist.com bla bla which is not really what I want.
Similar like function but instead for email, it's for domain:
function extract_email_address ($string) 
    {
       $emails = array();
       $string = str_replace("\r\n",' ',$string);
       $string = str_replace("\n",' ',$string);
       foreach(preg_split('/ /', $string) as $token) {
            $email = filter_var($token, FILTER_VALIDATE_EMAIL);
            if ($email !== false) { 
                $emails[] = $email;
            }
        }
        return $emails;
    }
 
    