[mapserver-users] [Feature Request] Ability to extract capture group contents from regex validation
Trond Michelsen
trondmm-mapserver+2017 at crusaders.no
Tue Jul 27 04:33:56 PDT 2021
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
More information about the MapServer-users
mailing list