The problem I'm facing is that upon following the question at this link, Using Regular Expressions to Extract a Value in Java, I am unable to extract the correct group of the String
Pattern p = Pattern.compile("I have .*");
Matcher m = p.matcher("I have apples");
if(m.find()){
System.out.println(m.group(0));
}
What I get:
I have apples
What I want to get:
apples
I've tried asking for m.group(1)
as well but it throws me an exception.
How should I go about this?