Thanks, Jack, this works too.
Yes, I must check Friedl's book!
Thanks again!
Am Samstag, 29. Dezember 2012 06:43:09 UTC+1 schrieb Jack Gates:
> On Fri, Dec 28, 2012 at 11:28 PM, MacVlad <vlad.ghitulescu@gmx.de> wrote:
> 
> > Hello!
> 
> >
> 
> >
> 
> > I have a text-file that looks like this:
> 
> >
> 
> > ---
> 
> > R UNZK904326 57075
> 
> > P UNZK904385 57127
> 
> > P UNZK904328 57053
> 
> > P ULZK908062 57101
> 
> > P UNZK904322 56498
> 
> > R UNZK904386 57108
> 
> > P UNZK904288 56383
> 
> > P UNZK904397 56383
> 
> > P UNZK904444 56878
> 
> > R UNZK904465 57253
> 
> > R UNEK919821 57025
> 
> > R UNEK919745 57259
> 
> > R UNZK904527 55769
> 
> > R UNEK919814 55944
> 
> > R ULZK908272 57376
> 
> > R UNZK904471 56355
> 
> > R ULZK908371 55393
> 
> > R UNZK904574 56646
> 
> > R UNEK919701 56974
> 
> > R UNZK904565 57598
> 
> > R UNZK904603 57649
> 
> > R ULZK908326 57471
> 
> > R UNZK904588 57610
> 
> > R ULZK908324 57514
> 
> > R ULZK908307 57614
> 
> > P ULZK908369 57149
> 
> > R UNZK904603 57649
> 
> > R UNEK919933 57643
> 
> > P ULEK935569 56373
> 
> > P ULEK935571 57504
> 
> > P ULZK908295 56122
> 
> > P ULZK908484 57149
> 
> > P UNEK919781 56816
> 
> > P UNEK919785 56747
> 
> > P UNEK919959 56615
> 
> > P ULEK935884 56951
> 
> > P ULEK935886 56845
> 
> > P UNZK904559 57572
> 
> > R ULEK935659 57784
> 
> > R ULEK935727 56203
> 
> > R ULEK935729 56474
> 
> > R ULEK935860 57871
> 
> > R ULEK935938 57946
> 
> > R ULEK935866 57885
> 
> > R ULZK908389 57584
> 
> > R ULZK908389 57743
> 
> > R ULZK908397 57707
> 
> > R ULZK908401 57743
> 
> > R ULZK908477 57647
> 
> > R ULZK908505 57853
> 
> > R ULZK908508 57672
> 
> > R UNZK904601 57598
> 
> > R UNZK904597 56581
> 
> > R ULZK908545 57897
> 
> > R ULZK908270 57469
> 
> > R UNZK904619 57688
> 
> > V ULZK908382 57724
> 
> > V ULZK908431 57724
> 
> > R UNZK904746 56581
> 
> > R ULZK908686 57754
> 
> > R ULEK935997 56474
> 
> > R ULZK908690 57975
> 
> > R ULEK936068 57999
> 
> > R ULZK908692 57208
> 
> > R ULEK935991 57956
> 
> > R ULZK908696 57955
> 
> > R ULEK936078 57983
> 
> > R UNZK904463 55662
> 
> > R ULEK936070 56010
> 
> > P ULEK936122 56478
> 
> > R ULZK908377 57623
> 
> > P ULEK936126 57671
> 
> > P ULEK936136 56784
> 
> > P ULEK936148 57102
> 
> > R UNEK920127 57622
> 
> > R UNZK904680 57294
> 
> > P ULEK936158 56303
> 
> > R ULEK935862 57800
> 
> > R ULZK908515 57636
> 
> > R ULEK935862 58097
> 
> > R ULEK936166 57800
> 
> > R ULZK908377 57623
> 
> > ---
> 
> >
> 
> > I want to make the following changes:
> 
> >
> 
> > 1.- Every time when a "R UN" in column 1 occurs, replace then the 5 digits ##### on column 14 (like 57075 in the first row) with "SM##### SLA KSR-Netz SST" (that would change the first row from "R UNZK904326 57075" to "R UNZK904326 SM57075 SLA KSR-Netz SST");
> 
> >
> 
> > 2.- For every row with "R UL" in column 1, replace then the 5 digits ##### on column 14 (like 57376 in the row 15) with "SM##### SLA KSR-Lief SST" (that would change the row 15 from "R ULZK908272 57376" to "R ULZK908272 SM57376 SLA KSR-Lief SST");
> 
> >
> 
> > 3.- Leave the others rows unchanged.
> 
> >
> 
> > Could you please help me with a regex in order to do this in VIM? Thank you!
> 
> 
> 
> Do this on the first one:
> 
> 
> 
> :%s/\(R UN\)\([A-Z]\{2}\d\{6}[ ]\)\(\d\{5}\)/\1\2SM\3 SLA KSR-Netz SST/g
> 
> 
> 
> Alter the pattern to do the same thing on the second one.
> 
> 
> 
> Check out Mastering Regular Expressions Third Edition by Jeffrey E. F. Friedl
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
No comments:
Post a Comment