Skip to main content
edited tags
Link
Donal Fellows
  • 138.8k
  • 19
  • 161
  • 222
Source Link
user554712
  • 211
  • 1
  • 3
  • 9

Regular expression capture groups which is in a group

In Java, how to get all groups which is inside a group (regular expression).
For example:Using (([A-Z][a-z]+)+)([0-9]+) test a string : "AbcDefGhi12345".
Then get Result:
matches():yes
groupCount():3
group(1):AbcDefGhi
group(2):Ghi
group(3):12345

But I want to get String "Abc", "Def", "Ghi", "12345" respectively.
How can I do that by using regular expression?