Split and trim the function value in Power automate

Loading

Requirement: How to split and trim the value in power automate using variable

Click on +Create > Instant flow> Provide a name for the flow> Manually trigger flow> Click on Create Button.

Next add Initialize variable action, Name > Type- Array>  Value-

[
“SUM”,

“EONH”,

“01MAR23”,

“PRELIM”
]

Next add an Compose action, Inputs- “PRELIM”

Next add another compose action and take an expression to split the value, for splitting the value use _ in the expression as

split(outputs('Compose'),'_')

The Split function breaks a text string into a table of substrings. Use Split to break up comma delimited lists, dates that use a slash between date parts, and in other situations where a well defined delimiter is used. A separator string is used to break the text string apart.

Next add another compose action and take an expression to trim the value, The Trim function removes all spaces from a string of text except for single spaces between words. The TrimEnds function removes all spaces from the start and end of a string of text but leaves spaces between words intact. Here the Variable that initialized are in 0,1,2,3 format so this trim expression is used to trim the 1st value, expression as

trim(variables('Name')[1])

Next add another compose action and take an expression to trim the value as

trim(outputs('Compose'))

It only displays the output of the first compose input.

Now save and run the flow here is the expected output.

Here the input contains Space and the trim expression is used.

The output is without space and the trim expression is used.

To check weather it has removed space or not click on Show raw output then it displays as shown in below

Leave a Reply

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