Java regex capture group?

Numbering of subgroups starts with 1, 0 is the full text. Just go till count+1 with your loop.

Up vote 2 down vote favorite share g+ share fb share tw.

String s ="xyz: 123a-45"; String patternStr="xyz: \\t*(\\S +)"; Pattern p = Pattern. Compile(patternStr); Matcher m = p. Matcher(s); //System.err.

Println(s); if(m.find()){ int count = m.groupCount(); System.out. Println("group count is "+count); for(int i=0;i Group(i)); } } java regex link|improve this question edited Jul 28 '11 at 20:48Tim Pietzcker61.6k43980 asked Jul 28 '11 at 20:40user1571956191521 64% accept rate.

1 More precisely, change the for loop condition to i.

This is because group's indices are starting with 1. Group 0 is the entire pattern. From the JavaDoc: "Capturing groups are indexed from left to right, starting at one.

Group zero denotes the entire pattern, so the expression m. Group(0) is equivalent to m.group(). " See more here.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions