users@jsr311.java.net

Re: URI template with regexp using nested curly braces.

From: Marc Hadley <Marc.Hadley_at_Sun.COM>
Date: Tue, 10 Mar 2009 13:46:28 -0400

On Mar 10, 2009, at 1:17 PM, Sergey Beryozkin wrote:
>> Specification says that URI template can specify regexp it matches.
>> It
>> does not state what kind of regexp can be used, I assume Java regexp
>> as default. In that case it is possible to use nested curly braces
>> e.g. "/area/{zipcode:[0-9]{5}}" to match "/area/90210".
>> What I am looking for is regular expression that catches template
>> variables. Problem is in Java regexp nested expression are hard (or
>> impossible) to express -- perl regexp syntax has additional
>> constructions that allow to catch nested closing brackets, Java's way
>> is not to get out from regexp grammar towards context-free grammars
>> that would allow to match such recursion problem.
>> Any ideas?
>
> Can someone confirm please that as far as handling expressions like
> "/area/{zipcode:[0-9]{5}}", it's up to
> a given implementation how to handle them and no assumption can be
> made that the default Java regexp should be used ?
>
How exactly an implementation supports regexs is up to the application
but I think all implementations need to support the same regex syntax.
I'd assumed the standard Java syntax would the one we'd use, it would
be odd to pick another one.

Marc.