Skip to main content
Became Hot Network Question
edited tags
Link
statox
  • 51.1k
  • 19
  • 158
  • 237
cleaned formatting; tags
Source Link
D. Ben Knoble
  • 28.9k
  • 3
  • 35
  • 71

-Every line is separated into 8 parts by colons

Input

-Every part can include words,numbers,space etc.

  • Every line is separated into 8 parts by semicolons
  • Every part can include words,numbers,space etc.

Output

I am trying to replace the space in the 6th part with a colonsemicolon, thus separating the line again, making the total number of parts 9.

Example

1;30;68;Az LEMda;Ads Awdsâ;1 Bethesda, Galilea, Impe Mkals;29;63  264;16 October 1978;2 April 2005;AAz Jgfg adal II;Madwl Qózca Asdtyła;20 May 1920 Maklo, Polasn;58;84 

would beend up like this

1;30;68;Az LEMda;Ads Awdsâ;1;Bethesda, Galilea, Impe Mkals;29;63  264;16 October 1978;2 April 2005;AAz Jgfg adal II;Madwl Qózca Asdtyła;20;May 1920 Maklo, Polasn;58;84 

Attempts

I tried to find the space using anything ranging from regex to \zs\zs but failed. ClosestThe closest I came was finding the 5th colonsemicolon.

%s/\(.\{-};\zs\)\{5}/;/g 

But iI need to find the space that comes after the number that comes after the 5th colonsemicolon, so this kind of thinking got me nowhere and now I am trying to find the space in the the parts that iI defined earlier. 

I could put awkawk into vim but then again I am fairly new with it. I managed to find the 6th part and change the space into a colonsemicolon, but then it changes all the spaces, not just the first one.

:%! awk 'BEGIN{FS=OFS=";"} {gsub(/ /, ";", $6)} 1' 

How can I just change the first space in the 6th part?

-Every line is separated into 8 parts by colons

-Every part can include words,numbers,space etc.

I am trying to replace the space in the 6th part with a colon, thus separating the line again, making the total number of parts 9.

1;30;68;Az LEMda;Ads Awdsâ;1 Bethesda, Galilea, Impe Mkals;29;63  264;16 October 1978;2 April 2005;AAz Jgfg adal II;Madwl Qózca Asdtyła;20 May 1920 Maklo, Polasn;58;84 

would be like this

1;30;68;Az LEMda;Ads Awdsâ;1;Bethesda, Galilea, Impe Mkals;29;63  264;16 October 1978;2 April 2005;AAz Jgfg adal II;Madwl Qózca Asdtyła;20;May 1920 Maklo, Polasn;58;84 

I tried to find the space using anything ranging from regex to \zs but failed. Closest I came was finding the 5th colon.

%s/\(.\{-};\zs\)\{5}/;/g 

But i need to find the space that comes after the number that comes after the 5th colon, so this kind of thinking got me nowhere and now I am trying to find the space in the the parts that i defined earlier. I could put awk into vim but then again I am fairly new with it. I managed to find the 6th part and change the space into a colon, but then it changes all the spaces, not just the first one.

:%! awk 'BEGIN{FS=OFS=";"} {gsub(/ /, ";", $6)} 1' 

How can I just change the first space in the 6th part?

Input

  • Every line is separated into 8 parts by semicolons
  • Every part can include words,numbers,space etc.

Output

I am trying to replace the space in the 6th part with a semicolon, thus separating the line again, making the total number of parts 9.

Example

1;30;68;Az LEMda;Ads Awdsâ;1 Bethesda, Galilea, Impe Mkals;29;63 264;16 October 1978;2 April 2005;AAz Jgfg adal II;Madwl Qózca Asdtyła;20 May 1920 Maklo, Polasn;58;84 

would end up like

1;30;68;Az LEMda;Ads Awdsâ;1;Bethesda, Galilea, Impe Mkals;29;63 264;16 October 1978;2 April 2005;AAz Jgfg adal II;Madwl Qózca Asdtyła;20;May 1920 Maklo, Polasn;58;84 

Attempts

I tried to find the space using anything ranging from regex to \zs but failed. The closest I came was finding the 5th semicolon.

%s/\(.\{-};\zs\)\{5}/;/g 

But I need to find the space that comes after the number that comes after the 5th semicolon, so this kind of thinking got me nowhere and now I am trying to find the space in the parts that I defined earlier. 

I could put awk into vim but then again I am fairly new with it. I managed to find the 6th part and change the space into a semicolon, but then it changes all the spaces, not just the first one.

:%! awk 'BEGIN{FS=OFS=";"} {gsub(/ /, ";", $6)} 1' 

How can I just change the first space in the 6th part?

added 171 characters in body
Source Link
arty
  • 145
  • 1
  • 6

-Every line is separated into 8 parts by colons

-Every part can include words,numbers,space etc.

I am trying to replace the space in the 6th part with a colon, thus separating the line again, making the total number of parts 9.

1;30;68;Az LEMda;Ads Awdsâ;1 Bethesda, Galilea, Impe Mkals;29;63 264;16 October 1978;2 April 2005;AAz Jgfg adal II;Madwl Qózca Asdtyła;20 May 1920 Maklo, Polasn;58;84 

would be like this

1;30;68;Az LEMda;Ads Awdsâ;1;Bethesda, Galilea, Impe Mkals;29;63 264;16 October 1978;2 April 2005;AAz Jgfg adal II;Madwl Qózca Asdtyła;20;May 1920 Maklo, Polasn;58;84 

I tried to find the space using anything ranging from regex to \zs but failed. Closest I came was finding the 5th colon.

%s/\(.\{-};\zs\)\{5}/;/g 

But i need to find the space that comes after the number that comes after the 5th colon, so this kind of thinking got me nowhere and now I am trying to find the space in the the parts that i defined earlier. I feel like I could do this withput awk -Finto vim but then again I need to learnam fairly new with it. I managed to find a way to set delimitersthe 6th part and change the space into a character of nth region in vimcolon, but then it changes all the spaces, not just the first one.

:%! awk 'BEGIN{FS=OFS=";"} {gsub(/ /, ";", $6)} 1' 

How can I just change the first space in the 6th part?

-Every line is separated into 8 parts by colons

-Every part can include words,numbers,space etc.

I am trying to replace the space in the 6th part with a colon, thus separating the line again, making the total number of parts 9.

1;30;68;Az LEMda;Ads Awdsâ;1 Bethesda, Galilea, Impe Mkals;29;63 264;16 October 1978;2 April 2005;AAz Jgfg adal II;Madwl Qózca Asdtyła;20 May 1920 Maklo, Polasn;58;84 

would be like this

1;30;68;Az LEMda;Ads Awdsâ;1;Bethesda, Galilea, Impe Mkals;29;63 264;16 October 1978;2 April 2005;AAz Jgfg adal II;Madwl Qózca Asdtyła;20;May 1920 Maklo, Polasn;58;84 

I tried to find the space using anything ranging from regex to \zs but failed. Closest I came was finding the 5th colon.

%s/\(.\{-};\zs\)\{5}/;/g 

But i need to find the space that comes after the number that comes after the 5th colon, so this kind of thinking got me nowhere and now I am trying to find the space in the the parts that i defined earlier. I feel like I could do this with awk -F but I need to learn to find a way to set delimiters and change a character of nth region in vim.

-Every line is separated into 8 parts by colons

-Every part can include words,numbers,space etc.

I am trying to replace the space in the 6th part with a colon, thus separating the line again, making the total number of parts 9.

1;30;68;Az LEMda;Ads Awdsâ;1 Bethesda, Galilea, Impe Mkals;29;63 264;16 October 1978;2 April 2005;AAz Jgfg adal II;Madwl Qózca Asdtyła;20 May 1920 Maklo, Polasn;58;84 

would be like this

1;30;68;Az LEMda;Ads Awdsâ;1;Bethesda, Galilea, Impe Mkals;29;63 264;16 October 1978;2 April 2005;AAz Jgfg adal II;Madwl Qózca Asdtyła;20;May 1920 Maklo, Polasn;58;84 

I tried to find the space using anything ranging from regex to \zs but failed. Closest I came was finding the 5th colon.

%s/\(.\{-};\zs\)\{5}/;/g 

But i need to find the space that comes after the number that comes after the 5th colon, so this kind of thinking got me nowhere and now I am trying to find the space in the the parts that i defined earlier. I could put awk into vim but then again I am fairly new with it. I managed to find the 6th part and change the space into a colon, but then it changes all the spaces, not just the first one.

:%! awk 'BEGIN{FS=OFS=";"} {gsub(/ /, ";", $6)} 1' 

How can I just change the first space in the 6th part?

added 32 characters in body
Source Link
arty
  • 145
  • 1
  • 6
Loading
Source Link
arty
  • 145
  • 1
  • 6
Loading