I need help to extract values from string req.url.path which looks like this:
/a/b/c/d
Need to extract c, if there is url, like /a, it should return ''.
I tried
regsub(req.url.path, "/a/b/", "\5");
Tried with replace too. but it is not effectively working for me. Please help me.
I believe the following might be along the lines of what you require:
It checks if the URL path begins with
/aand is followed by/c(presuming also that there are segments in-between, such as/bas per your given example/a/b/c/d).Here is a Fastly Fiddle link for you to play around with the code:
https://fiddle.fastlydemo.net/fiddle/527480ba
So given the input URL path:
It would change to:
Notice that the
/chas been extracted from the path.