Re: stripping html tags

From: Date: Mon, 06 Jun 2005 01:36:01 +0000
Subject: Re: stripping html tags
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-216456@lists.php.net to get a copy of this message
On 6/6/05, Richard Lynch <ceo@l-i-e.com> wrote: > On Sun, June 5, 2005 7:05 am, Dotan Cohen said: > > I took this example from php.net, but can't figure out where I went > > wrong. Why does this: > > $text = preg_replace("/<head(.|\s)*?>(.|\s)*?<\/head>/i" , > > "" , $text); > > > > throw this error: > > syntax error at line 265, column 39: > > $text = > > preg_replace("/<head(.|\s)*?>(.|\s)*?<\/head>/i" , "" , $text); > > ======================================^ > > > > It seems to be pointing to the 'e' is 'head'. Why? Thanks. > > The pointing is often "off" by a few chars... > > For starters, you're not correctly using \, imho. > > \ is special in PHP strings. > \ is ALSO special in RegEx. > > So your \s should be \\s, in case PHP makes \s special someday. > > I think the ?> in there will also mess you up, maybe, as that ends PHP > parsing... Though it SHOULD be kosher inside a string... > > -- > Like Music? > http://l-i-e.com/artists.htm > > Could well be- I certainly didn't come up with that regex myself! What would you recommend to remove any tag, and the code enclosed? For instance: "I love my <tag>big</tag> brother" would become "I love my brother"? Dotan http://lyricslist.com/lyrics/pages/artist_albums.php/114/Chapman%2C%20Tracy Tracy Chapman Lyrics

« previous php.general (#216456) next »