cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Replace number with generic string

educampver
Dynatrace Advisor
Dynatrace Advisor

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!

1 REPLY 1

stefan_eggersto
Dynatrace Mentor
Dynatrace Mentor

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))

stefan_eggersto_0-1685616880988.png

 

 

Featured Posts