Replace specific elements (unique or duplicates) from a string in JS
问题 My code automatically search the string for /d+d/d+ elements (roll dices) and adds random number suffixes and stores them as elements in an array. I want to create a new string with the new modified elements of my array. (I don't want to split string in Array, replace the same elements with the other array in a brand new one and then join it to a string. I need to modify it and save it in a new string) Example: String changes through user input so if i have: str = ' I roll 1d3 and 2d4+3 and