How to split strings into AA using phobos

John Chapman johnch_atms at hotmail.com
Tue Dec 11 09:59:45 UTC 2018


On Tuesday, 11 December 2018 at 08:20:32 UTC, Arun Chandrasekaran 
wrote:
> A typical example would be to split the HTTP query string into 
> an AA.
>
> vibe.d has req.queryString, but no convenient wrapper to access 
> it as an AA.
>
> http://localhost/hello?name=abc&id=123
>
> I've got this far.
>
>         auto arr = req.queryString.splitter('&').map!(a => 
> a.splitter('='));
>
> Thanks

req.queryString[req.queryString.indexOf('?') + 1 .. $]
   .splitter('&')
   .map!(a => a.splitter('='))
   .map!(a => tuple(a.front, a.back))
   .assocArray


More information about the Digitalmars-d-learn mailing list