I have a file having lines as:ram_reg_10/raja_reg_9/raghu_reg_8  abc_reg_4/bcd_reg_5  cad/pqr_reg_91 I want to convert string _reg_number into [number] at only last of every line in vi editor.output should be:ram_reg_10/raja_reg_9/raghu[8]  abc_reg_4/bcd[5]  cad/pqr[91]  I tried::%s?_reg_[0-9]$?\[[0-9]\]?gBut it gives:  ram_reg_10/raja_reg_9/raghu[[0-9]]  abc_reg_4/bcd[[0-9]]  cad/pqr_reg_91how to do it?
add bracket across numbers at only end of each line
regular expression;vi
In command mode::%s/_reg_\([0-9]\+\)$/[\1]/Here we use \+ to match one or more group of numbers at the end. So we don't have substitute with lines like cad/pqr_reg_.