regular expressions and Phone validation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi all,

I have one small problem I don't understand the preg_replace() method.
 I understand the gist of what it does but I still don't fully know
what it does.  I have read the entry in the php manual about this and
I am still confused about it. I've never been any good with regular
expressions.

Here is the function in use:

function checkPhone ($Phone)
{
        global $errmsg;
                if (!empty($Phone))
		{
			$Phone = ereg_replace("[^0-9]", '', $Phone);
			
			if ((strlen($Phone)) <= 14)
				return preg_replace("/[^0-9]*([0-9]{3})[^0-9]*([0-9]{3})[^0-9]*([0-9]{4}).*/",
"(\\1) \\2-\\3",$Phone);
		}
}

I think my problem is mostly what is returned when preg_replace executes?

Paul

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux