Re: EREGI_REPLACE? HELP!!!

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

 



On Thu, 20 Jan 2005 11:19:10 -0600, Kiason Turner <pctech@xxxxxxxxxxxxx> wrote:
> I'm trying to take a string and remove all "invalid characters" from it.
> 
> $string="Frid#ays are@ re$ally G{}[]RE~AT. F*rid<>ay at 5 is be^tt&er.";
> 
> The only characters that should be allowed are A-Z, a-z, 0-9,
> .(period), -(dash), ;(semi-colon), and :(colon).
> All other characters should be removed.
> After "cleaning" the string, the output should be: "Fridays are really
> GREAT. Friday at 5 is better."
> 
> Any ideas? Your help is appreciated.

Maybe something like:

$string = ereg_replace( "[^-.:;[:alnum:][:space:]+]", '', $string );

I'm no regex guru so there may be a better way.. but it seemed to work for me.


-- 
Greg Donald
Zend Certified Engineer
http://destiney.com/

-- 
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