Search code examples
dataweavemule-esb

DataWeave Mule : Extract from String data after particular character


I have a requirement to extract data from a string after the occurence of '@'. Example abc@123456 should result in 123456. I am doing htis in DataWeave Mule.

Kindly suggest


Solution

  • You should use splitBy for this, then grab what you need by index:

    %dw 1.0
    %output application/java
    
    %var data = ("abc@123456" splitBy "@")[1]
    ---
    data
    

    This will set the payload to String: "123456"