简体   繁体   中英

Replace Everything between Name and Title In Mule

I am getting a Long URL as String which contains query parameters (Name, Title, Location). I like to Replace Name and Title with Position.

Values in the Name and Title are unique for every request.

Incoming Request:

{
    "url":"https://test.com/IncomingRequest?Name=MuleSoft&Title=Developer&Location=Headquaters"
}

Excepted Output:

{
    "url" : "https://test.com/IncomingRequest?Position=North&Location=Headquaters"
}

Using regex:

%dw 1.0
%output application/json

%var input = {"url" : "https://test.com/IncomingRequest?Name= MuleSoft&Title=Developer&Location=Headquaters"}
---
url: input.url replace /Name.+?(?=&Location)/ with "Position=North"

Output:

{
  "url": "https://test.com/IncomingRequest?Position=North&Location=Headquaters"
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM