Hi, @sakijhon, @Terry-R and All,
I understood why I wrongly supposed that it could be some spaces, at end of fields. Just because, analyzing the initial OP’s lines, with the TextFX option Line up multiple lines by (Clipboard Character), the plugin added some space chars to get all : separators aligned. And somehow, I probably used pieces of text containing these blank chars :-((
So, Terry, you’re right and, probably, blank characters do not exist before or after semicolons, in the OP’s text. Thus, the search regex can be simplified as below. Note, also, that the replacement remain unchanged :-))
SEARCH (?-s)^(.+?:){6}((.+?):){3}.+
REPLACE \1\3
Wow ! We just have learned a useful rule, regarding delimiter-separated format files :-))
Let’s imagine, for instance, a file, containing, exactly, 12 fields, with the ! exclamation mark as a delimiter char.
Now, let’s suppose that you would extract the 3rd, 5th, 6th and 11th fields, only, from that file
So, we start with this sample text :
3.00000!0.0009900000!S!{0}!frankgotti@me.com!frankie!Tucson!456789!student!marketing!approved!last field, line 1 3.50000!0.3010299957!C!{2}!chary@hotmail.com!charoty!!orth_Oracle!567234!notstudent!mathematics!disapproved!last field, line 2 3.75000!0.6020500913!S!{2}!tytarty@yagoo.com!tiagonne!Mission_District!126789!teacher!course_algebra!teacher!last field, line 3We, first do simple subtractions in order to determine all the coefficients, used as quantifiers, in the regex :
Fld | Qtf 3 - 0 = 3 \ 5 - 3 = 2 \ 6 - 5 = 1 \ 11 - 6 = 5This leads to these correct regexes :
SEARCH (?-s)^(.+?!){3}(.+?!){2}(.+?!)((.+?)!){5}.+
REPLACE \1\2\3\5
OR
SEARCH (?-s)^(.+?!){3}(.+?!){2}(.+?!)(?:(.+?)!){5}.+
REPLACE \1\2\3\4
And… we get the expected results :
S!frankgotti@me.com!frankie!approved C!chary@hotmail.com!charoty!disapproved S!tytarty@yagoo.com!tiagonne!teacherEt voilà !
Cheers,
guy038
P.S. :
In case of unwanted space characters, right before or after any separator, it is more sensible to do the preliminary S/R, below :
SEARCH \x20+Separator\x20+
REPLACE Separator