Regex for recursive "wiki-style" lists
Posted
by Syd Miller
on Stack Overflow
See other posts from Stack Overflow
or by Syd Miller
Published on 2010-05-21T07:16:30Z
Indexed on
2010/05/21
7:20 UTC
Read the original article
Hit count: 285
I'm trying to create a Regular Expression to match "wiki style" lists as in (using preg_replace_callback() ):
* List Item 1
* List Item 2
*# List Item 2.1
*# List Item 2.2
* List Item 3
Asterisks denote Unordered Lists while Number-Signs denote Ordered Lists. I'm trying to get this so it can match infinite depth and so that * and # can be mixed.
I tried the following expression (and variations of it): /\s([*#]{1,}) ([\S ]+)\s/si
But it doesn't seem to want to work.
What am I doing wrong? Or is there a better way of accomplishing this?
© Stack Overflow or respective owner