vamsi
4 years agoNew Contributor II
Split String by appending a new value after every 3 characters from the end
Hi All,
Need help with the below scenario…
I have a value A341B22C01D91E80 I wanted to have this split from the end after every 3 characters and append with +
So my output should be A+341+B22+C...
- 4 years ago
Using a mapper and assuming your input text is at the key
$text
you can use the following expression to achieve your goal:$text.split("").reverse().reduce((accum, cur) => (accum.length - accum.split("+").length +1) % 3 == 0 ? accum + "+" + cur: accum + cur).split("").reverse().join("")