Reply to Re: [PHP] EREGI_REPLACE? HELP!!!

Your name:

Reply:


Posted by Greg Donald on 01/20/05 20:16

On Thu, 20 Jan 2005 11:19:10 -0600, Kiason Turner <pctech@cantexinc.com> 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/

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация