Hello,
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?
TIA
Daniel
Daniel:
/^(\d{6})(\d{4})$/
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)
@danielsoderlund
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.
Daniel Kimmelmann:
$length($string(OrgNo)) = 10 ? $split($string(OrgNo),/.{4}$/,3)[0] & β-β & $split($string(OrgNo),/.{6}/,3)[1] : OrgNo
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
system
(system)
Closed
April 11, 2024, 4:45pm
11
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.