Skip to Main Content

Java Programming

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: named group capturing?

807589Nov 13 2006 — edited Jun 27 2008
Hi, I know that in JAVA regular expression "capturing groups are numbered by counting their opening parentheses from left to right", but is there anyway to assign a name to a capturing group, like the way in python:

(?P<year>[0-9][0-9][0-9][0-9]) //see regular expression Howto website

where this group is named "year" and and be retrieved by the group name.

Can I do this in JAVA regex? Any hints please, thanks!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 25 2008
Added on Nov 13 2006
4 comments
410 views