Re: PREG-pattern, help needed

From: Date: Thu, 11 Sep 2003 15:02:06 +0000
Subject: Re: PREG-pattern, help needed
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-162305@lists.php.net to get a copy of this message
Hi Tobias, This matches more than you'd like because [td] will match anything that has a t in it or a d in it. More generally anything in brackets means the RegExp will try to match something from that set. What you might want is this: preg_replace('/<td[^>]*>/i', "<td id='$counter'>"); The preg replaces <td> or <td with stuff inside> to what you wanted. -d "Tobias Talltorp" <tobias@talltorp.com> wrote in message news:20030909162252.2720.qmail@pb1.pair.com... > I need help with a preg-pattern for preg_replace_callback(). > > I need to match <td(+all properties)> and replace them with <td > id=$counter>. > > // this pattern is all wrong, since it matches and replaces all tags > echo preg_replace_callback("|(<[td][^>]+>)|i", "bla", $html); > > ?> > > > Any thoughts? > // Tobias

« previous php.general (#162305) next »