In a flow add character to string


I get this string from a API 0123465789 and in a Flow I need to translate it to 012345-6789 before I can post it to another API.

Looked at Manipulate data in FQL | Postman Learning Center

and only way I think it can be done is with Manipulate data in FQL | Postman Learning Center

with a regex /^(\d{6})(\d{4})$/ and then I need to join them with - between,
This is me guessing so if it can be done in this way I need some help with howto.

Any other take on this?


Something like this or can it be done in one go ?

I think I’m going to get a number from the API

I have come to this now but I get a strange output.
I want 123456-7890

And it’s not working if I have more then 10 numbers.

$split($string(OrgNo),/.{4}$/,3) & "-" & $split($string(OrgNo),/.{6}/,3)


The $split function returns an array so you have to select the component of the array in order to get just the number:

$split($string(OrgNo),/.{4}$/,3)[0] & "-" & $split($string(OrgNo),/.{6}/,3)[1]

However you mention it doesn’t work for numbers longer than 10 digits. What would you like the output to be if it’s more than 10 digits? is the pattern {first 6} - {everything else} ?

Thanks, didn’t read anything that I could select the value as well.
If it’s more then 10 I would like to have the whole as it is.

Try this then:

$length($string(OrgNo)) = 10 ? $split($string(OrgNo),/.{4}$/,3)[0] & "-" & $split($string(OrgNo),/.{6}/,3)[1] : OrgNo

If the length equals 10 then perform the logic to split it, if the length is anything else, then return the whole number.

You have some documentation on how to build Query like that ?

@danielsoderlund It’s combining the $split function from earlier with the ternary operator (fql docs on it here).

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.