How can I extract the data that is inside the brackets with their respective position?
let str = 'Aqui esta [pepe] y [pepito]';
resultado=str.split(" ")
[ 'Aqui', 'esta', '[pepe]', 'y', '[pepito]' ]
in this case you should get the word pepe in position 2 and 4 in pepito to be able to save an object with the position and the word
You can try to replace the characters in this way. This in case the structure is not changing.
Suggested reading:
https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/map
you can do it like this: