Reputation: 6241
I have an xml file that contains, among other tags, a sequence of page
tags that look like the following (the ellipses are just to show content that is not included):
<page1 ...>
...
</page>
<page2 ...>
...
</page>
<page3 ...>
...
</page>
This is my Eclipse IDE regex search expression:
(?s)<page.*</page>
The search results are returning one match; everything between <page1
and the very last </page>
element. I'm trying to get it to return 3 matches, one for each element. How can I achieve this?
Upvotes: 0
Views: 83
Reputation: 174796
.*
is greedy by default. That is, it matches all the characters as far as it can (longest possible match). By adding the quantifier ?
next to the *
forces the regex engine to do a non-greedy match (shortest possible match).
(?s)<page.*?<\/page>
(?s)
Dotall modifier which makes the dot in your regex to match even line breaks.
Upvotes: 1