S
stevengarcia
I want to extract all the content between HTML <li> tags. I'm using
regular expressions and I'm not capturing every match with my regex.
What I have is:
String regex = "<li>(.*)</li>";
String content = "<html><li>aaa</li><li>bbb</li></html>";
Pattern p = Pattern.compile(regex);
Matcher matcher = p.matcher(content);
while (matcher.find()) {
System.out.println(matcher.group(1));
}
The result of this is "aaa</li><li>bbb" and that is not what I want. I
instead want to just print "aaa" and "bbb". What am I doing wrong?
Thanks for your help.
regular expressions and I'm not capturing every match with my regex.
What I have is:
String regex = "<li>(.*)</li>";
String content = "<html><li>aaa</li><li>bbb</li></html>";
Pattern p = Pattern.compile(regex);
Matcher matcher = p.matcher(content);
while (matcher.find()) {
System.out.println(matcher.group(1));
}
The result of this is "aaa</li><li>bbb" and that is not what I want. I
instead want to just print "aaa" and "bbb". What am I doing wrong?
Thanks for your help.