0

My String page contain this page http://www.posh24.se/kandisar and I want to extract everything between

<div class="channelListEntry"> 

and

</div>

and put the result into an ArrayList.

The things is the matcher.find() always returns false.

private ArrayList<String> extracted = new ArrayList<String>();

    public void extractChannel(String htmlPage){

    Pattern pattern = Pattern.compile("<div class=\"channelListEntry\">(.*?)</div>");
    Matcher matcher = pattern.matcher(htmlPage);

    while(matcher.find()){ // Always return false
        System.out.println("hello ?");
        extracted.add(matcher.group(1));
    }
}

I expect to copy the text between tags in my array.

Sotirios Delimanolis
  • 274,122
  • 60
  • 696
  • 724
faradiel
  • 3
  • 1
  • 4
    Use an XML parser instead of regex matching. https://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags – Adam McClenaghan May 01 '19 at 00:57

1 Answers1

0

Add Pattern.DOTALL flag when compiling the pattern so it matches multilines - https://stackoverflow.com/a/2913756/9335036

Z. Kosanovic
  • 727
  • 4
  • 10