Page 2 of 2

Posted: Wed Jun 16, 2004 11:34 pm
by feyd
[google]man page grep[/google]

Posted: Thu Jun 17, 2004 4:35 pm
by tim
google for tutorials

check out the one at ZEND if you come across it, very helpful.

also search for "redmonkey" here, he has helped alot of people with regExs

Posted: Thu Jun 17, 2004 5:41 pm
by redmonkey
In the example given in the fist post there is actually an obvious pattern in that there is an opening tag '[bbtag:uid]' and a closing tag '[/bbtag:uid]' so it would be quite easy to apply a regex to find the opening tag then everything in between and up to the matching closing tag then replace that with just the text in between.

Code: Select all

$data[$i]['topic_text'] = preg_replace('/\[([^\]]+)](.*?)\[\/\\1]/s', '$2', $data[$i]['topic_text']);
However there are a few special cases (color= etc..) so the regex needs to be extended slightly (untested)....

Code: Select all

$data[$i]['topic_text'] = preg_replace('/\[(\w+)(?:=[^:]+)?(:[^\]]+)](.*?)\[\/\\1\\2]/s', '$3', $data[$i]['topic_text']);
So I reckon it could be done with a single (or possibly two) regex without too much hassle.