Reputation: 5667
I'm trying to build a list and increment a counter for each list item that has a particular keyword. I'm unable to compile this. Why?
int count = 0;
String keyword = args[1];
Pattern p = Pattern.compile(keyword);
Matcher m = p.matcher(p);
/* For each paragraph in the document... */
for (XWPFParagraph paragraph : paragraphs) {
/* Add to List */
words.add(paragraph.getText());
System.out.println(paragraph);
/* Iterate keyword count */
while (m.find()) {
count++;
}
}
Upvotes: 0
Views: 36
Reputation: 14373
The problem is probably here
Matcher m = p.matcher(p);
the argument should be the text to search
Matcher m = p.matcher(paragraph.getText());
Upvotes: 1