Use the backreference in a regex to replace a text dynamically
问题 I want to use the $1 value like an integer. The idea is to replace all numbers from originaltext with the equivalent array values and create a new text. The below desired outcome should be "This is DBValue4, This is DBValue2, This is DBValue7" Also, is there a way to save these backreferences for further use? String[] values = {"DBValue0","DBValue1","DBValue2","DBValue3","DBValue4","DBValue5","DBValue6","DBValue7","DBValue8","DBValue9","DBValue10"}; String originaltext = "This is 4, This is 2