I have a string like: The zoo has a panda named {{123}} that is colored {{234}}
I have an array that represents each one of the tokens like:
[ { label: 'Ralph', id: '123' }, { label: 'White and Black', id: '234' } ]
I want to traverse the string and replace the {{token}}
with the actual label BUT i also need to keep track of the character position that I'm replacing. Ralph would be position 26 character. A trickier scenario would be: after I replace {{123}}
with Ralph
the text position of color would be different since Ralph is 5 characters and the token was 7 characters.
Any thoughts on the fastest approach to solving this?