preg_replace replace whole string
my preg_replace replaces my whole string instead of just the bit where the expression fits.
Code:
http://beta.yapaste.com/bd
This is what I want replaced:
<t开发者_Python百科able id=\"post24100391\" style=\"width: 100%;\" class=\"p4\" >
Thanks for help.
yes..... that regex matches the entire table.... it will replace the entire string with $replace.
what is it you want to replace?
You could use capturing replacement...
preg_replace("/(<table.*?>).*(<\/table>)/","\$1$replace\$2},$str);
Or you could use a non-capturing group around the parts to not replace...
e.g.
preg_replace("/(?:<table.*?>).*(?:<\/table>)/",$replace,$str) //not tested, though
EDIT in response to OP change
preg_replace("/<table.*?>/",$replace,$str);
You wanted to use lazy capturing *?
精彩评论