That's what I thought, too. But it doesn't work.

test.php:

$text = '<ul> [*] jusfj [*] ijusnf [*] jsf [*] jusdf </ul>';
$text = preg_replace('/\[\*\]([^(\[\*\])(<\/ul>)]*)/i','<li>$1</li>',$text);
$text = htmlentities($text);

Output:

<ul> <li> j</li>usfj <li> ij</li>usnf <li> jsf </li><li> j</li>usdf </ul>

I tested some different things, which didn't work. Any more ideas
are appreciated.

Jens

> 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
> >



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to