Split By Function

How to split a string into Array in MuleSoft using Split By function.

This function is part of core module. It helps splitting a string into a string array on the basis of a value that matches the original string.

Step 1:

Add the transform Message Component in the mule flow from component palette.

Step 2:  

In this component we can write the Dataweave script to split a string into array as shown below. We can click on Preview button to see the resultant of Dataweave operation.

Dataweave Expression:

%dw 2.0

Output application/json

var x=  “12.13.15”

x splitBy “.”

Output:  [





Here “.” is matched in the original string “12.13.15” and an array is  returned. The resultant array will exclude the matching string from the original string.

Reference Link: https://docs.mulesoft.com/mule-runtime/4.3/

Leave a Reply

Your email address will not be published. Required fields are marked *