$re = '/(?<li_all>
(?<li_lead_line>\n)?
(?<li_lead_space>^[ \t]*)
(?<list_type_any>
(?:
(?:
(?<list_type_unordered_star>(?&list_unordered_star))
|
(?<list_type_unordered_minus>(?&list_unordered_minus))
|
(?<list_type_unordered_plus>(?&list_unordered_plus))
)
|
(?<list_type_ordered>(?&list_ordered))
)
)
[ \t]*
(?<li_content>(?s:.*?)
(\n{1,2}))
(?= \n*
(
\z
|
\g{li_lead_space}
(?<list_type_any2>
(?:
(?:
(?<list_type_unordered_star2>(?&list_unordered_star))
|
(?<list_type_unordered_minus2>(?&list_unordered_minus))
|
(?<list_type_unordered_plus2>(?&list_unordered_plus))
)
|
(?<list_type_ordered2>(?&list_ordered))
)
)
[ \t]*
)
)
)
(?(DEFINE)
(?<list_unordered_star>
[\*]
(?!
(?:
[ ]?[\*][ ]?
){2,}
)
)
(?<list_unordered_minus>
[\-]
(?!
(?:
[ ]?[\-][ ]?
){2,}
)
)
(?<list_unordered_plus>[\+])
(?<list_ordered>\d+[\.])
)/mxJ';
$str = '* JKL
1. JKL-1
2. JKL-2
';
preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0);
// Print the entire match result
var_dump($matches);
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for PHP, please visit: http://php.net/manual/en/ref.pcre.php