[mapserver-users] [Feature Request] Ability to extract capture group contents from regex validation

Steve Lime sdlime at gmail.com
Wed Jul 28 12:09:48 PDT 2021


Interesting idea, certainly not crazy. I'm not sure what's possible with
regex libs commonly used with MapServer builds.

On Tue, Jul 27, 2021 at 6:34 AM Trond Michelsen <
trondmm-mapserver+2017 at crusaders.no> wrote:

> This sounds like a good idea to me, but I would suggest to use named
> capture groups. In perl, this uses this syntax: (?<name>pattern). So,
> in this example, it could be:
>
> "datetime" "^(?<year>[0-9]{4})[-_](?<month>[0-9]{2})[-_](?<day>[0-9]{2})$"
> # <- 3 capture groups
>
> And the result could then be used in substitution as: %year%, %month%
> and %day%. Maybe with an added prefix, but I'd prefer without, tbh.
>
> On Tue, Jul 27, 2021 at 06:12:44AM +0000, Sommer, Ashley (L&W, Dutton
> Park) wrote:
> > Hi All,
> > This is slightly related to my previous thread today, but more general.
> >
> > I want to gauge interested in this idea.
> > I want to be able to use Runtime Substitution mechanisms to do something
> like this:
> >
> > MAP
> >   ...
> >   VALIDATION
> >     "datetime" "^([0-9]{4})[-_]([0-9]{2})[-_]([0-9]{2})$" # <- 3 capture
> groups
> >   END
> >
> >   LAYER
> >     DATA "/mnt/dataset/%datetime_1%/%datetime_2%/%datetime_3%.tif"
> >     ...
> >   END
> >   ...
> > END
> >
> > Where the query with &datetime=2018-01-29 is split into parts using
> capture groups 1, 2, and 3 from the validation regex, and stored as new
> runtime substitution variables: %datetime_1%, %datetime_2%, and
> %datetime_3%.
> > Then using these values, substitute them into the DATA string (or any
> other valid substitution point).
> > Substituted:
> > DATA "/mnt/dataset/2018/01/29.tif"
> >
> > The regex mechanism to validate the incoming parameter value is already
> in place, and it seems like just one more little step is needed to save the
> captured groups into new runtime substitution variables.
> >
> > - Ashley Sommer
>
> > _______________________________________________
> > mapserver-users mailing list
> > mapserver-users at lists.osgeo.org
> > https://lists.osgeo.org/mailman/listinfo/mapserver-users
>
>
> --
> Trond Michelsen
> _______________________________________________
> mapserver-users mailing list
> mapserver-users at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/mapserver-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20210728/77d162f0/attachment.html>


More information about the mapserver-users mailing list