java - 正则表达式能不能匹配指定字符串中间的内容?
怪我咯
怪我咯 2017-04-18 09:18:25
0
1
293

现在有个XML类似:

<aaa>
<bbb>
<ccc>
1|+|2|+|3|+|4
5
6|+|7
</ccc>
</bbb>
</aaa>

我想找出两个|+|中间的内容里的换行,也就是4后边的一个换行,5后边的一个换行,正则能实现么?

怪我咯
怪我咯

走同样的路,发现不同的人生

reply all(1)
Ty80

In this case you need to match twice, the first time两个|+|中间的内容

\|\+\|[\s\S]+?\|\+\|

The matching result is:

[1]:|+|2|+|
[2]:|+|4
5
6|+|

Then perform a second match separately:

\w\n

The result is

共找到 2 处匹配:
4

5
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template