mlavwilson Posted October 9, 2006 Share Posted October 9, 2006 I am using xoops, and thier news module insists on replacing slash-n with br. The problem is when I try to insert tables into an article I get a huge amount of br. I am weak on regex, can someone help me with a regex to remove all the slash-n that occure between the start and end table...slash-n...table? Quote Link to comment Share on other sites More sharing options...
effigy Posted October 9, 2006 Share Posted October 9, 2006 [code]<pre><?php $data = <<<DATA <html> <body> before <table> <tr> <td>abc</td> </tr> <tr> <td>123 </td> </tr> </table> after </body> </html>DATA; function clean_table ($matches) { ### Remove new lines. $table_content = preg_replace("/\r\n/", '', $matches[1]); ### Clean up space between end/start tags. return $table_content = preg_replace('/(?<=>)\s+(?=<)/', '', $table_content); } echo $data = preg_replace_callback('%(?<=<table)(.+?)(?=/table>)%sm', 'clean_table', $data);?></pre>[/code] Quote Link to comment Share on other sites More sharing options...
mlavwilson Posted October 9, 2006 Author Share Posted October 9, 2006 Many thanks! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.