jakarta-regexp-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Vadim Gritsenko <vadim.gritse...@verizon.net>
Subject Re: Project enhancement proposal
Date Thu, 04 Dec 2003 13:29:47 GMT
Walid Joseph Gedeon wrote:

>Hello all,
>
>    Euh, ping! (Am I on, or is it really a low traffic list? :)
>  
>

Yes, you are; and yes, it is.


>    I was working on an interesting project and found the need to extend
>the Regexp functionality by defining a meta-structure that combines
>regexps together... and was wondering if there would be interest to
>include such an expansion.
>
>    The need is to be able to extract matched values from an input text,
>for example, say an input is:
>
>        key is = thefirstkey, value is = thefirstvalue
>
>then we would like to say that (actually, this is the format that I have
>implemented):
>
>        (^key is = ){param1=([:alphanum:]*)}(, value is =
>){value1=([:alphanum:]*)}($)
>
>would match it and return a map with ["param1"->"thefirstkey",
>"param2"->"thesecondkey"]
>  
>
...

>    Have I been wasting time implementing something that already exists?
>  
>

Simple regexp:
    ^key is = ([:alphanum:]*), value is = ([:alphanum:]*)$

Will return you two parens, first one is value for param1, and second 
one is value for value1. Put values in the map, and you are done. You 
can also define generic paren list -> values map mapping (and store it 
in separate string, not in regexp itself), and use this mapping to 
populate result map from paren list:
    String[] map =  { null, "param1", "value1" };
    for (...) results.put(map[i], re.getParen(i));


>    If this is a good idea, how do we go about submitting it for general
>code review and the sort? (I'm going through the docs about this that
>are on the site)
>  
>

I'm not sure that this is a good idea because:
(a) this is not a part of any regexp stadard (AFAIU). If I'm mistaken, 
point me to the docs.
(b) you are introducing two new special symbols: '{' and '}'


Vadim



---------------------------------------------------------------------
To unsubscribe, e-mail: regexp-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: regexp-dev-help@jakarta.apache.org


Mime
View raw message