01 Jun 2023 07:55 AM
Hi,
How can I replace a numeric (or other pattern) string with a generic one? For example, my DQL query returns:
/v1/shipments/customer-picked-up
/v1/shipments/containers/100000011782/hold-locations
/v1/shipments/2023051723300410000038807/assigned-user
But I'd like to format them into something like this:
/v1/shipments/customer-picked-up
/v1/shipments/containers/[n]/hold-locations
/v1/shipments/[n]/assigned-user
Thanks!
Solved! Go to Solution.
01 Jun 2023 11:54 AM
Hi @educampver ,
you can use the parse
command to extract the part before and after the pattern, and append
to join the parts, including a replacement string:
data record(a="/v1/shipments/customer-picked-up"), record(a="/v1/shipments/containers/100000011782/hold-locations"), record(a="/v1/shipments/2023051723300410000038807/assigned-user")
| parse a, "'/v1/' LD:b int LD:c"
| fields result = if(isNull(b), a, else:concat(b,"[n]",c))