Re: RegExp for Forum-List-Code
| From: | Marek Kilimajer | Date: | Sat, 09 Nov 2002 16:56:23 +0000 |
| Subject: | Re: RegExp for Forum-List-Code | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-123594@lists.php.net to get a copy of this message | ||
untested:
preq_replace('/\[\*\]([^(\[\*\])(<\/ul>)]*)/i','<li>$1</li>',$text);
Jens Lehmann wrote:
Hi out there, I encountered a lot of problems while trying to convert a list in Forum-Code (like UBB-Code). [list] [*] item 1 [*] item 2 [*] item 3 [/list] should be converted to <ul> <li>item 1</li> <li>item 2</li> <li>item 3</li> </ul> I converted the first one to <ul> [*] item 1 [*] item 2 [*] item 3 </ul> Now I need a Regexp for converting every [*] foo to <li>foo</li>. I started with $text = preq_replace('/\[\*\]([^(\[\*\])]*)/i','<li>$1</li>',$text); The RegExp starts from [*] and saves every char in $1 until [*] occurs again. That's fine, but what I need is a RegExp which starts from [*] and saves every char in $1 until [*] OR </ul> occurs in $text. I tested a lot, but didn't find a solution. I'd be glad about any help. Jens