Re: Removing UTF-8 from text

From: Date: Wed, 03 Jan 2007 18:22:34 +0000
Subject: Re: Removing UTF-8 from text
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-246473@lists.php.net to get a copy of this message
Why not simply capture what you want, rather than try to remove what you don't want? preg_match_all("%<([\w\d@.]+)>%", $text, $matches); now print_r($matches[1]) and you see your addresses A little better code might be, sense it is more explicit and less prone to pick up malformed addresses. preg_match_all("%<([\w\d@]+.\w{3,4})>%", $text, $matches); Make a new file with: $new_file= ''; foreach($matches[1] as $addr){ $new_file .= $addr . "<br>"; } Al..... Dotan Cohen wrote:
I have many email address that are stored like this: "=?UTF-8?B?15jXqNeR15XXp9eZ16DXlCDXnteo15nXkNeg15Q=?=" <name@place.com>, "=?UTF-8?B?15nXoNem158g157XqNeZ15Q=?=" <person@domain.com>, "=?UTF-8?B?15zXmSDXpNeV15zXmdeg15Q=?=" <human@site.net> I'm trying to run a script that will leave the file as so: name@place.com, person@domain.com, human@site.net The first step is to remove the UTF-8 names. This code _doesn't_ work, but I think that it should: $text=preg_replace('/\"=\?UTF\-8\?B\?([a-z0-9]+)\?=\"/i', '', $text); I've tried with single and double quotes, and I've tried backslashing and not backslashing the question marks. Where am I erring? Thanks. Dotan Cohen http://technology-sleuth.com/long_answer/what_are_the_advantages_of_lcd_monitors.html http://kubuntu.info


« previous php.general (#246473) next »