string replace using regex groups code example
Example 1: replace with regex capture group
str.replace(/(?<=name="\w+)\d+(?=\w+")/, '!NEW_ID!') // look behind & look ahead
Example 2: replace with regex capture group
str.replace(/(.*name="\w+)\d+(\w+".*)/, "$1!NEW_ID!$3")