I've got the following string:
<div>Some headline - list 1<br />
> List item 1<br />
> List item 2<br />
> List item 3<br />
<br />
List 2<br />
> foo<br />
> bar<br />
> baz<br />
<br />
</div>
It contains two maleformed lists. It is my goal to wrap the items of these lists into <ul>
. To accomplish that, I am looking for a regex that matches all Items of each list into one match group.
So my expected result would be:
> List item 1<br />
> List item 2<br />
> List item 3<br />
and
> foo<br />
> bar<br />
> baz<br />
All regex magic I tired failed because they did match only a single line of the list, or the match group was including all the content between the beginning of the first list and the end of the last one.
I've tried ~> (.*)<br />\\s~gis
~> (.*)<br />\\s~gis
which matches both of the lists.
You can try this regex, To capture only the Lists.,
Im using java regex.,
(> .*(?:<br\s/>\s+List\s2<br\s/>)?)
It captures these elements.,
> List item 1<br />
> List item 2<br />
> List item 3<br />
> foo<br />
> bar<br />
> baz<br />
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.