Parsing URL to extract data

,

In DQL, I’m trying to parse an url to extract usefull data.

Example: https://api-services.unknown.com/env/v6/permissions/check

I want to extract api version which is v6 in this case. Then, I want all the following, which would be /permissions/check

Both data would be in separate fields.

I have tried a lot things with parse but never managed to do it, whether it would be simple with a classic regexp.

I have read DPL Grammar documentation as well as DPL Lines and Strings, but I don’t understand how to build the parse command for my need.

Right now, I am using this: | fieldsAdd relativePath = substring(requestUrl, from: indexOf(requestUrl, “/”, from: 8))

It isn’t very good, but it is still better than the full url !

With parsing command would be something like this:

data record (a = "https://api-services.unknown.com/env/v6/permissions/check")
| parse a, "LD 'env/' LD:apiversion '/' LD:rest "

See if helps

env text is an example, it could be anything else.

I just tried try this:

| parse requestUrl, “LD ‘/v’ INT:versionNum ‘/’ DATA:apiPath”
| fieldsAdd apiVersion = concat(“v”, toString(versionNum))
| fieldsAdd apiEndpoint = concat(“/”, apiPath)

So far, it seems to work fine.