replace regex capture group code example
Example 1: replace with regex capture group
print(readline().replace(/(\d+)(.) ?/g,(a,b,c)=>c.repeat(b)))
Example 2: replace with regex capture group
str.replace(/(.*name="\w+)\d+(\w+".*)/, "$1!NEW_ID!$3")
Example 3: replace with regex capture group
str.replace(/(?<=name="\w+)\d+(?=\w+")/, '!NEW_ID!') // look behind & look ahead