Re: Replacing text with criteria

From: Date: Fri, 16 Jun 2006 00:32:26 +0000
Subject: Re: Replacing text with criteria
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-238126@lists.php.net to get a copy of this message
Try with preg_replace('/\d(?!(?>\d*)\))/X', '*', $phone) wich would be a bit more efficient than preg_replace('/\d(?!\d*\))/X', '*', $phone) Jeff Lewis wrote:
I have been working on a script to parse a CSV file and in the process I clean out a lot of the garbage not needed but I am a bit stumped on one aspect of this file. It's a list of over 3000 contacts and I'm trying to mask a lot of the information with *. So as I loop through this list I am checking the array elements as if I find a phone number (555) 555-1212 (I was searching for the (555)) I want to convert it to (555) ***-**** For fields not containing an area code, I wanted any text to be replaced by an * except for the first and last letter in the element. I'm stumped and was hoping that this may be something horribly simple I'm overlooking that someone can point out for me. -- Atentamente / Sincerely, J. Rafael Salazar Magaña


« previous php.general (#238126) next »