I'm creating a little CMS for work, and am allowing users to use "BBCode" style tags to format their text.
I am allowing them to insert (very) basic tables too, using a set of [ TABLE ], [ ROW ], and [ COL ] tags.
However, I'm also converting line breaks in the text to <br />, so if someone types in this:
[ TABLE ]
[ ROW ]
[ COL ]Hello[ /COL ]
[ /ROW ]
[ /TABLE ]
Then the table ends up halfway down the page because of the <br /> that gets put at the end of each line.
How can I trap these in the regular expression? The regular expression I'm using so far is:
"\\[TABLE\\](.*?)\\[\/TABLE\\]" => "<table border=\"0\" cellspacing=\\"4\\" cellpadding=\\"4\\">\\\\1</table>",
"\\[ROW\\](.*?)\[\\/ROW\\]" => "<tr>\\\\1</tr>",
"\\[COL\\](.*?)\[\\/COL\\]" => "<td>\\\\1</td>",
(using arrays to do a preg_replace, so the search pattern is in the array key, and the replace pattern in the keys value)
I've tried using \n* but it doesn't seem to match.
Can anyone help?