| Computers Forum Index » Computer - Editors » vim substitution... |
|
Page 1 of 1 |
|
| Author |
Message |
| Andy... |
Posted: Thu Sep 24, 2009 2:23 pm |
|
|
|
Guest
|
Hi there,
Imagine we have a text file with the following content:
"1st Jan","First day"
"2nd Jan",""Second day"
"3rd Jan","Third day"
"4th Jan","Fouth day"
and we want to remove the date suffixes "st, nd, rd and th" to get:
"1 Jan","First day"
"2 Jan",""Second day"
"3 Jan","Third day"
"4 Jan","Fouth day"
In vim is it possible to do a substitution along the lines of:
:%s/[0-9][a-z][a-z]/[0-9]/g
this will replace the number with [0-9]. Is it possible to get vim to
leave the number as it is?
Many thanks
Andrew |
|
|
| Back to top |
|
|
|
| Andrew 2006... |
Posted: Thu Sep 24, 2009 3:07 pm |
|
|
|
Guest
|
|
| Back to top |
|
|
|
| Christian Brabandt... |
Posted: Thu Sep 24, 2009 11:44 pm |
|
|
|
Guest
|
On 2009-09-24, Andrew 2006 <mymatebob at (no spam) googlemail.com> wrote:
regards,
Christian
--
Time is money. Especially if you make clocks. |
|
|
| Back to top |
|
|
|
| Peter Gordon... |
Posted: Thu Oct 01, 2009 5:05 am |
|
|
|
Guest
|
Andy <mymatebob at (no spam) googlemail.com> wrote in news:3e310264-6da8-4dde-ab60-
77dba9aa8d36 at (no spam) q14g2000vbi.googlegroups.com:
Quote: "1st Jan","First day"
"2nd Jan",""Second day"
"3rd Jan","Third day"
"4th Jan","Fouth day"
Use:
:%s/\(\"[0-9]*\)[A-Za-z]* \(.*\)/\1 \2/ |
|
|
| Back to top |
|
|
|
|