Let's keep this simple.Input:- abc- def- ghiDesired output (whitespace optional):<ul>    <li>abc</li>    <li>def</li>    <li>ghi</li></ul>Current code:$output = preg_replace_callback(    ((^- (.*)$\r*\n*)+)m,    function($m) {        return <ul><li>.            implode(                </li><li>,                preg_split(                    (^- )m,                    substr($m[0],2)                )            ).            </li></ul>;    },    $input);It works, the output is exactly what I want, but it seems kinda... hackish. Having a preg_split inside a preg_replace_callback seems a bit redundant, but I can't seem to find a way of capturing subpatterns that are inside a quantifier. If I could do that then I would implode the subpatterns rather than having to split the matched part again.Any suggestions?
Bulleted list from dashes
php;regex
Wouldn't this give you the desired output:$result = '<ul>' . preg_replace('/^- (.*)$/m', '<li>$1</li>', $subject) . '</ul>';Update:$output = preg_replace_callback(    ((^- (.*)$\r*\n*)+)m,    function($m) {        return '<ul>' . preg_replace('/^- (.*)$/m', '<li>$1</li>', $m) . '</ul>';    },    $input);