I have following text in a file
23456789
When I tried to replace the above text using command
1,$s/\(\d\)\(\d\d\d\)\(\d\d\)*\>/\3\g
I am getting 89. Shouldn’t it be 6789? Can anyone tell me why it is 89.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Group 3 is defined as being 2 digits long. If you want to match the last 4 digits you want
\(\d\d\d\d\)with no*at the end. If you just want to match all digits but the first 4, put your*inside the group match rather than outside.