I\'m trying to code a regexp to convert a block of text:
* List item
* Another list item
to html:
-
On this question, if you where talking about the fact that the code you used would wrap multiple sets of li tags in one ul tag even if there was suppose to be a break in there like so:
* line 1
* line 1
* line 1
this is not part of a list
* line 1
* line 1
* line 1
Would become:
- line 1
- line 1
- line 1
this is not part a the list
- line 1
- line 1
Then I have a solution for you. You had 90% of it there, here is a solution I came up with (but I am sure you already solved it anyway):
$text = preg_replace("/\*+(.*)?/i","- $1
",$text);
$text = preg_replace("/(\<\/ul\>\n(.*)\*)+/","",$text);
The solution does not mess with lists of any kind already on the page in the text or whatever and makes sure to separate multiple lists. Reason is that every match it finds where an asterisk was used to create a text list item it surrounds that with a ul and li then the 2nd line finds all of the back to back closing and opening ul tags and removes them.