If I have a regex with a capturing group, e.g. foo(_+f). If I match this against a string and want to replace the first capturing group in all matches with baz ...
I'm trying to figure out how to replace just part of a match using the java regex classes (or some other set). Say I have a regex like this: (\\d*)-(\\d*) It will match strings like this: 4-3 100-5656 1-1 I would like to use string replace on the 2nd group, but I am not sure how. If I use string.replace(matcher.group(2), ....) ...