- From: Manger, James H <James.H.Manger@team.telstra.com>
- Date: Wed, 14 Nov 2007 16:17:32 +1100
- To: <uri@w3.org>
The previous regex I sent was not quite correct.
To parse { prefix[^] variable [*separator] [^]suffix [|default] }, including the shortcuts, you can use 1 of 2 regexes depending if any ^’s are present.
If ^ appears in the segment use:
\{
([^^]*)\^
([^*^|}]*)
(?:\*([^^|}]*))?
(?:\^([^|}]*))?
(?:\|([^}]*))?
\}
If ^ does NOT appear in the segment use:
\{
([^|}]*?)
((?<==)(?=[^a-zA-Z])|
[a-zA-Z][a-zA-Z0-9._~-]*)
(?:\*([^|}]*))?
([^|}=a-zA-Z0-9._~-]*)
(?:\|([^}]*))?
\}
Both regexes have the same (…) groups in the same order so subsequent processing is identical.
-----Original Message-----
From: Manger, James H
Sent: Monday, 12 November 2007 5:24 PM
To: 'uri@w3.org'
Subject: URI Templates: {prefix^variable*separator^suffix|default}
Next modification of my proposal:
{ prefix[^] variable [*separator] [^suffix] [|default] }
If <variable> is undefined, replace with
<default>
If <variable> is a single value, replace with
<prefix><variable><suffix>
If <variable> is a list of 2 values, replace with
<prefix><variable[0]><separator><variable[1]><suffix>
A <prefix> in the form ?name= or &name= is treated specially.
If no question mark already appears in the URI under construction, for the prefix use
?<name>=
Otherwise, for the prefix use
&<name>=
There are some shortcuts for convenience:
{prefix^var*} is a shortcut for {prefix^var*prefix}, which is useful for query parameters that can repeat.
{prefixvar} is a shortcut for {prefix^var}, but is only allowed if unambiguous (eg <prefix> ends with a <reserved> character).
{varsuffix} is shortcut for {var^suffix}, but is only allowed if unambiguous (eg <suffix> starts with a <reserved> character other than * and contains no <alpha> chars). {/name/} -> /alice/
{?name=} and {&name=} are shortcuts for {?name=name} and {&name=name}.
Omitting <default> or <suffix> is a shortcut for including them as an empty string.
…
Received on Wednesday, 14 November 2007 05:18:00 UTC