Sadly, the REGEXP function is only for string comparison, not substitution. You'll either have to handle the replacement on the client side or string together an unwieldy series of REPLACE functions, like so:
SET @phone = '(123) 456-7890';
SELECT REPLACE( REPLACE( REPLACE( REPLACE(@phone, ' ', ''), '(', ''), ')', ''), '-', '') AS phone; +------------+ | phone | +------------+ | 1234567890 | +------------+
You'll probably need to add more REPLACE statements for things like periods and various common abbreviations ('x', 'ext.', and 'EX', for instance). In the future, you should probably try to clean up your data before it gets into the database. It'll make your life a lot easier.
____________________________________________________________ Eamon Daly
----- Original Message ----- From: "Chris Ramsay" <[EMAIL PROTECTED]>
To: "Jerry Swanson" <[EMAIL PROTECTED]>
Cc: <mysql@lists.mysql.com>
Sent: Thursday, April 28, 2005 6:37 AM
Subject: Re: REPLACE function
If I understand your problem, MySQL allows you to use regular expressions - so you could use the REGEXP function to remove the spaces. Check out the mysql site...
Chris
-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]