Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Regex: help needed on backreferences for nested capturing groups

763890Mar 10 2010 — edited Mar 10 2010
Hello, everyone

I'm confused with backreferences for the nested capturing group(s). Can anyone help me out to understand it?
Well, I knew that the following regular expression would match any 2 digits, followed by the exact same two digits:
(\d\d)\1
BUT, how about a nested capturing group? How would it be evaluated?
(\d\d(confused))\2
In the expression (\d\d(\d)), there are two groups:
1.itself, (\d\d(confused))
2.nested group, (confused)

And, *\2* here specifies that is the second pattern (confused) that I want to use for matching? Urr.... totally confused.

Edited by: Jay-K on Mar 10, 2010 3:39 PM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 7 2010
Added on Mar 10 2010
6 comments
848 views