Re: ereg_replace

From: Date: Tue, 30 Sep 2003 15:36:27 +0000
Subject: Re: ereg_replace
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-30771@lists.php.net to get a copy of this message
From: "Dillon, John" <JDillon@cantor.co.uk> > strip_tags() is used to remove HTML tags, eg for showing text on the browser > and then sending it by plain text email or storing in the db. As a matter > of interest, how is this done using ereg_replace. I thought this would work > ^<.*>$, that is being with < and any number of single characters ending with > >. Didn't seem to work - why? Because you have ^ and $ (beginning of string and end of string), you're saying the entire string must be between < and > in order for a match to occur. Take them out and make sure you're not being "greedy", i.e. "this <tag> and that <tag> are left" being reduced to "this are left". ereg_replace('<[^>]*>','',$string); or preg_replace('/<[^>]*>/','',$string); should work. ---John Holmes...

« previous php.db (#30771) next »