A/B/1 A/B/5 A/B/8 A/B/9
C/D/1?XYZ C/D/5?XYZ C/D/8?XYZ C/D/9?XYZ
replace 'A/B/(\d+)' with 'C/D/\1?XYZ'
\1 refers to the first match in the regular expression. The first match is (\d+) in the replace string. (\d+) means find one or more digits, that is a character 0-9.