PDA

View Full Version : regex for cleaner.php



Delioncourt
Fri 3rd Aug '07, 1:57am
I am having a problem with the regular expression to use with cleaner.php in order to completely remove the following phpBB 2 BBcode while keeping the text between the tags:


[offtopic:522a0ada7e] text I want to keep [/offtopic:522a0ada7e]The numbers and letters inside the offtopic tags are ofcourse random.

Jerry
Fri 3rd Aug '07, 9:46pm
This will wrap it in quote tags :



$text = preg_replace('#\[offtopic:([a-z0-9]+)\](.*)\[/offtopic:\\1\]#siU', '
$2', $text);

This will remove the offtopic tags completely :



$text = preg_replace('#\[offtopic:([a-z0-9]+)\](.*)\[/offtopic:\\1\]#siU', '$2', $text);

Delioncourt
Wed 8th Aug '07, 4:37pm
Thanks a lot I couldn't figure it out myself.. The '$2' was the issue in my case. It worked like a charm thanks again for your help !