Hi there!
I am writing a little script that checks if a string has an asterisk efter newline (\n) and then replaces this so it becomes a bulleted list. Like this:
$text = preg_replace( "/(?:^\*)([^\n]+)(?:$)/m", "<ul><li>\\1</li></ul>", $text );
Okay. So that works. But if the $text looks like this:
\n*Hello\n*Hello2
My regexp will output:
<ul><li>Hello</li></ul><ul><li>Hello2</li></ul>
But I would like it to output:
<ul><li>Hello</li><li>Hello2</li><ul> (note the missing </ul><ul>)
...so that it becomes one bulleted list instead of to (or more).
Is there any easy solution to this?
Thanks in advance / jek