Re: RegExp for Forum-List-Code
| From: | Jens Lehmann | Date: | Sat, 09 Nov 2002 18:55:25 +0000 |
| Subject: | Re: RegExp for Forum-List-Code | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-123607@lists.php.net to get a copy of this message | ||
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
> >