[prev in list] [next in list] [prev in thread] [next in thread]
List: jakarta-oro-user
Subject: Re: AW: Named Subgroups
From: Hannes Koller <hkoller () ifit ! uni-klu ! ac ! at>
Date: 2005-09-16 10:01:32
Message-ID: 432A97FC.2060702 () ifit ! uni-klu ! ac ! at
[Download RAW message or body]
Thanks for your quick reply. :-)
The problem is, that I actually have several regular expressions. To be
more specific I will give you an actual example (although a very simple
one. I am afraid I have more complex problems to solve, but the
principle is essentially the same) :
I am working on an Information Extraction Task. I have a Regular
Expression which matches a Number with a Unit.. something like " 12
cm " .. i want to have a subgroup, which returns the number part of
the match, and an other subgroup wich returns the unit part. So far this
would be easy with just the subgroup numbering that ORO Provides
(Group1 = number part, Group 2 = unit part).
My Problem is that numbers can also be written like this "cm 12" ,
which can be found by a different regular expression, but then the
groups which contain the number and unit part of the match are
switched. (Group 1 = unit , Group 2 = number).
What I want to do is have a (probably large) List of Regular
Expressions which all match certain "Number with Unit" patterns, and
access the number and unit parts of this matches in a consistent way.
(always with match.getGroup("Number") and match.getGroup("Unit"). I
hope this helps to clarify why I need to actually *name* the groups in a
match, and can not use the sequential numbering.
Regards,
Hannnes
Michael Rachow wrote:
>I'm not sure about understanding your actual problem,
>but maybe creating simple constants
>like static int DAY = 1 and using match.getGroup(DAY)
>would give you some more transparency?
>
>Regards,
>Michael
>
>-----Ursprüngliche Nachricht-----
>Von: Hannes Koller [mailto:hkoller@ifit.uni-klu.ac.at]
>Gesendet: Freitag, 16. September 2005 11:18
>An: oro-user@jakarta.apache.org
>Betreff: Named Subgroups
>
>
>Hi,
>I have been using ORO for some time and have encountered a problem. I
>need to give names to Subgroups (Instead of (or in addition to) the
>numbering that is done automatically). Is there a way to do something like
>
> (?<Day>\d{2})/(?<Month>\d{2})/(?<Year>\d{4})
>
> which should produce 3 named subgroups (Day, Month, Year) and access
>them in java like
>
> match.getGroup("Day")
>
>
>Is a feature like this already implemented in ORO and I am missing it,
>or is it planned for the near future? This would greatly ease my task. TIA
>
>Hannes Koller
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: oro-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: oro-user-help@jakarta.apache.org
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: oro-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: oro-user-help@jakarta.apache.org
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: oro-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: oro-user-help@jakarta.apache.org
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic