I have this regex:
<a href(.*foo.bar.*)a>
For this string, it gives me only 1 match, but I need it to give 3 matches.
<a href="https://foo.bar/1">First</a> RANDOM TEXT COULD BE HERE <a href="https://foo.bar/2">Second</a> RANDOM TEXT COULD BE HERE <a href="https://foo.bar/3">Third</a>
So each a href
should be individual.
How could I accomplish this?
EDIT:
This code searches for matches:
Pattern pattern = Pattern.compile("<a href(.*foo.bar.*)a>");
Matcher matcher = pattern.matcher(body);
List<String> matches = new ArrayList<String>();
while (matcher.find()) {
matches.add(matcher.group());
}