Reputation: 1
I have a problem in Regular expression. I need to print and count the words starts with word ‘ge’ and end with either word ‘ne’ or ‘me’. When I running the code only words start with "ge" appear. Can anyone help me to improve my source code?
Pattern p = Pattern.compile("ge\\s*(\\w+)");
Matcher m = p.matcher(input);
int count=0;
List<String> outputs = new ArrayList<String>();
while (m.find()) {
count++;
outputs.add(m.group());
System.out.println(m.group());
}
System.out.println("The count is " + count);
Upvotes: 0
Views: 104