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
/a
and is followed by/c
(presuming also that there are segments in-between, such as/b
as 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
/c
has been extracted from the path.