Hi! I've written a regular expression to strip out BBCode tags - it just strips the allowed tags out (for later counting the string length without the tags).
I'm not an expert when it comes to regular expressions - so after an hour I found this pretty much working:
$pattern = "/\[\/?(i|b|u|url(.*?)|list|li)[\]\[]*\]/i";
$stripped = preg_replace($pattern, '', $text);
It only strips the allowed six tags (and no more - which it is supposed to) and the special tag 'url' which can be extended like 'url=http://someurl'.
I.e.
in: [url=someurl]Lorem[/url] ipsum [test]dolor[/test] sit [b]amet[/b].
out: Lorem ipsum [test]dolor[/test] sit amet.
But the problem is, that it doesn't just strip out 'url=[sometext]' but also 'urlipsum'. I tried to add an '=' for parsing but couldn't get to the point.
Does anyone has a hint for me how to only strip out url when it comes with the =?