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" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> 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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to