remove comma from a specific portion of a long string
Clash Royale CLAN TAG#URR8PPP
up vote
6
down vote
favorite
I have document contain very long strings represent decoded information, i want to remove ,
commas from the last portion of the string. For example this is one of the long strings:
Insert into PE_ATRT_S(ID_ANA_TX,FQ_WQ_ASDF,ID_PRTY,NM_ATHY_TX,SC_RND,QU_DGT_RND) values (99990987868959,null,68,'T59 - %,Dsc,Itm-2 tax 1 Juris',4,5);
I want to remove comma from the last portion of it so let me zoom in to show you how it look like:
(99990987868959,null,68,'T59 - %,Dsc,Itm-2 tax 1 Juris',4,5);
so the final result look like this:
Insert into PE_ATRT_S(ID_ANA_TX,FQ_WQ_ASDF,ID_PRTY,NM_ATHY_TX,SC_RND,QU_DGT_RND) values (99990987868959,null,68,'T59 - % Dsc Itm-2 tax 1 Juris',4,5);
please notice the last portion of the long string, no comma in part of it let's zoom in to see it better:
(99990987868959,null,68,'T59 - % Dsc Itm-2 tax 1 Juris',4,5);
I spent hours trying to find a way to do it but I failed, would you please help me to fix these strings, thanks!
text-processing
add a comment |Â
up vote
6
down vote
favorite
I have document contain very long strings represent decoded information, i want to remove ,
commas from the last portion of the string. For example this is one of the long strings:
Insert into PE_ATRT_S(ID_ANA_TX,FQ_WQ_ASDF,ID_PRTY,NM_ATHY_TX,SC_RND,QU_DGT_RND) values (99990987868959,null,68,'T59 - %,Dsc,Itm-2 tax 1 Juris',4,5);
I want to remove comma from the last portion of it so let me zoom in to show you how it look like:
(99990987868959,null,68,'T59 - %,Dsc,Itm-2 tax 1 Juris',4,5);
so the final result look like this:
Insert into PE_ATRT_S(ID_ANA_TX,FQ_WQ_ASDF,ID_PRTY,NM_ATHY_TX,SC_RND,QU_DGT_RND) values (99990987868959,null,68,'T59 - % Dsc Itm-2 tax 1 Juris',4,5);
please notice the last portion of the long string, no comma in part of it let's zoom in to see it better:
(99990987868959,null,68,'T59 - % Dsc Itm-2 tax 1 Juris',4,5);
I spent hours trying to find a way to do it but I failed, would you please help me to fix these strings, thanks!
text-processing
add a comment |Â
up vote
6
down vote
favorite
up vote
6
down vote
favorite
I have document contain very long strings represent decoded information, i want to remove ,
commas from the last portion of the string. For example this is one of the long strings:
Insert into PE_ATRT_S(ID_ANA_TX,FQ_WQ_ASDF,ID_PRTY,NM_ATHY_TX,SC_RND,QU_DGT_RND) values (99990987868959,null,68,'T59 - %,Dsc,Itm-2 tax 1 Juris',4,5);
I want to remove comma from the last portion of it so let me zoom in to show you how it look like:
(99990987868959,null,68,'T59 - %,Dsc,Itm-2 tax 1 Juris',4,5);
so the final result look like this:
Insert into PE_ATRT_S(ID_ANA_TX,FQ_WQ_ASDF,ID_PRTY,NM_ATHY_TX,SC_RND,QU_DGT_RND) values (99990987868959,null,68,'T59 - % Dsc Itm-2 tax 1 Juris',4,5);
please notice the last portion of the long string, no comma in part of it let's zoom in to see it better:
(99990987868959,null,68,'T59 - % Dsc Itm-2 tax 1 Juris',4,5);
I spent hours trying to find a way to do it but I failed, would you please help me to fix these strings, thanks!
text-processing
I have document contain very long strings represent decoded information, i want to remove ,
commas from the last portion of the string. For example this is one of the long strings:
Insert into PE_ATRT_S(ID_ANA_TX,FQ_WQ_ASDF,ID_PRTY,NM_ATHY_TX,SC_RND,QU_DGT_RND) values (99990987868959,null,68,'T59 - %,Dsc,Itm-2 tax 1 Juris',4,5);
I want to remove comma from the last portion of it so let me zoom in to show you how it look like:
(99990987868959,null,68,'T59 - %,Dsc,Itm-2 tax 1 Juris',4,5);
so the final result look like this:
Insert into PE_ATRT_S(ID_ANA_TX,FQ_WQ_ASDF,ID_PRTY,NM_ATHY_TX,SC_RND,QU_DGT_RND) values (99990987868959,null,68,'T59 - % Dsc Itm-2 tax 1 Juris',4,5);
please notice the last portion of the long string, no comma in part of it let's zoom in to see it better:
(99990987868959,null,68,'T59 - % Dsc Itm-2 tax 1 Juris',4,5);
I spent hours trying to find a way to do it but I failed, would you please help me to fix these strings, thanks!
text-processing
text-processing
edited 7 hours ago
Jeff Schaller
33.8k851113
33.8k851113
asked 7 hours ago
Zahi
181111
181111
add a comment |Â
add a comment |Â
3 Answers
3
active
oldest
votes
up vote
9
down vote
accepted
awk -F' -vOFS=' 'gsub(","," ",$2); print'
Nice solution. Just one bug : it will work only with lines having one'...,...'
field.
â George Vasiliou
6 hours ago
@GeorgeVasiliou This solution can be made more general:awk -F' -vOFS=' 'for(n=1;n<=NF;n++)if(n%2==0)gsub(","," ",$n) print'
.
â simlev
5 hours ago
@simlev: You can omit the filter on the iteration counter if you adjust the iteration start and step size:for (n = 2; n <= NF; n += 2) gsub(",", " ", $n);
â David Foerster
3 hours ago
add a comment |Â
up vote
2
down vote
Alternative solution with gnu sed
:
sed -r 's/(x27.*),(.*x27)/1 2/g' file
x27
: ascii code of single quote '
Nice way of working around'
, but this removes only the last of the commas inside the single quotes, giving%,Dsc
instead of% Dsc
as was requested by the OP. I solved this issue using recursion.
â simlev
5 hours ago
add a comment |Â
up vote
0
down vote
Perl showcase:
perl -pe "1 while s/'.*K,(?=.*')/ /" input.txt
Output:
Insert into PE_ATRT_S(ID_ANA_TX,FQ_WQ_ASDF,ID_PRTY,NM_ATHY_TX,SC_RND,QU_DGT_RND) values (99990987868959,null,68,'T59 - % Dsc Itm-2 tax 1 Juris',4,5);
Zoomed output:
(99990987868959,null,68,'T59 - % Dsc Itm-2 tax 1 Juris',4,5);
add a comment |Â
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
9
down vote
accepted
awk -F' -vOFS=' 'gsub(","," ",$2); print'
Nice solution. Just one bug : it will work only with lines having one'...,...'
field.
â George Vasiliou
6 hours ago
@GeorgeVasiliou This solution can be made more general:awk -F' -vOFS=' 'for(n=1;n<=NF;n++)if(n%2==0)gsub(","," ",$n) print'
.
â simlev
5 hours ago
@simlev: You can omit the filter on the iteration counter if you adjust the iteration start and step size:for (n = 2; n <= NF; n += 2) gsub(",", " ", $n);
â David Foerster
3 hours ago
add a comment |Â
up vote
9
down vote
accepted
awk -F' -vOFS=' 'gsub(","," ",$2); print'
Nice solution. Just one bug : it will work only with lines having one'...,...'
field.
â George Vasiliou
6 hours ago
@GeorgeVasiliou This solution can be made more general:awk -F' -vOFS=' 'for(n=1;n<=NF;n++)if(n%2==0)gsub(","," ",$n) print'
.
â simlev
5 hours ago
@simlev: You can omit the filter on the iteration counter if you adjust the iteration start and step size:for (n = 2; n <= NF; n += 2) gsub(",", " ", $n);
â David Foerster
3 hours ago
add a comment |Â
up vote
9
down vote
accepted
up vote
9
down vote
accepted
awk -F' -vOFS=' 'gsub(","," ",$2); print'
awk -F' -vOFS=' 'gsub(","," ",$2); print'
answered 7 hours ago
Goro
8,13753978
8,13753978
Nice solution. Just one bug : it will work only with lines having one'...,...'
field.
â George Vasiliou
6 hours ago
@GeorgeVasiliou This solution can be made more general:awk -F' -vOFS=' 'for(n=1;n<=NF;n++)if(n%2==0)gsub(","," ",$n) print'
.
â simlev
5 hours ago
@simlev: You can omit the filter on the iteration counter if you adjust the iteration start and step size:for (n = 2; n <= NF; n += 2) gsub(",", " ", $n);
â David Foerster
3 hours ago
add a comment |Â
Nice solution. Just one bug : it will work only with lines having one'...,...'
field.
â George Vasiliou
6 hours ago
@GeorgeVasiliou This solution can be made more general:awk -F' -vOFS=' 'for(n=1;n<=NF;n++)if(n%2==0)gsub(","," ",$n) print'
.
â simlev
5 hours ago
@simlev: You can omit the filter on the iteration counter if you adjust the iteration start and step size:for (n = 2; n <= NF; n += 2) gsub(",", " ", $n);
â David Foerster
3 hours ago
Nice solution. Just one bug : it will work only with lines having one
'...,...'
field.â George Vasiliou
6 hours ago
Nice solution. Just one bug : it will work only with lines having one
'...,...'
field.â George Vasiliou
6 hours ago
@GeorgeVasiliou This solution can be made more general:
awk -F' -vOFS=' 'for(n=1;n<=NF;n++)if(n%2==0)gsub(","," ",$n) print'
.â simlev
5 hours ago
@GeorgeVasiliou This solution can be made more general:
awk -F' -vOFS=' 'for(n=1;n<=NF;n++)if(n%2==0)gsub(","," ",$n) print'
.â simlev
5 hours ago
@simlev: You can omit the filter on the iteration counter if you adjust the iteration start and step size:
for (n = 2; n <= NF; n += 2) gsub(",", " ", $n);
â David Foerster
3 hours ago
@simlev: You can omit the filter on the iteration counter if you adjust the iteration start and step size:
for (n = 2; n <= NF; n += 2) gsub(",", " ", $n);
â David Foerster
3 hours ago
add a comment |Â
up vote
2
down vote
Alternative solution with gnu sed
:
sed -r 's/(x27.*),(.*x27)/1 2/g' file
x27
: ascii code of single quote '
Nice way of working around'
, but this removes only the last of the commas inside the single quotes, giving%,Dsc
instead of% Dsc
as was requested by the OP. I solved this issue using recursion.
â simlev
5 hours ago
add a comment |Â
up vote
2
down vote
Alternative solution with gnu sed
:
sed -r 's/(x27.*),(.*x27)/1 2/g' file
x27
: ascii code of single quote '
Nice way of working around'
, but this removes only the last of the commas inside the single quotes, giving%,Dsc
instead of% Dsc
as was requested by the OP. I solved this issue using recursion.
â simlev
5 hours ago
add a comment |Â
up vote
2
down vote
up vote
2
down vote
Alternative solution with gnu sed
:
sed -r 's/(x27.*),(.*x27)/1 2/g' file
x27
: ascii code of single quote '
Alternative solution with gnu sed
:
sed -r 's/(x27.*),(.*x27)/1 2/g' file
x27
: ascii code of single quote '
answered 6 hours ago
George Vasiliou
5,34031027
5,34031027
Nice way of working around'
, but this removes only the last of the commas inside the single quotes, giving%,Dsc
instead of% Dsc
as was requested by the OP. I solved this issue using recursion.
â simlev
5 hours ago
add a comment |Â
Nice way of working around'
, but this removes only the last of the commas inside the single quotes, giving%,Dsc
instead of% Dsc
as was requested by the OP. I solved this issue using recursion.
â simlev
5 hours ago
Nice way of working around
'
, but this removes only the last of the commas inside the single quotes, giving %,Dsc
instead of % Dsc
as was requested by the OP. I solved this issue using recursion.â simlev
5 hours ago
Nice way of working around
'
, but this removes only the last of the commas inside the single quotes, giving %,Dsc
instead of % Dsc
as was requested by the OP. I solved this issue using recursion.â simlev
5 hours ago
add a comment |Â
up vote
0
down vote
Perl showcase:
perl -pe "1 while s/'.*K,(?=.*')/ /" input.txt
Output:
Insert into PE_ATRT_S(ID_ANA_TX,FQ_WQ_ASDF,ID_PRTY,NM_ATHY_TX,SC_RND,QU_DGT_RND) values (99990987868959,null,68,'T59 - % Dsc Itm-2 tax 1 Juris',4,5);
Zoomed output:
(99990987868959,null,68,'T59 - % Dsc Itm-2 tax 1 Juris',4,5);
add a comment |Â
up vote
0
down vote
Perl showcase:
perl -pe "1 while s/'.*K,(?=.*')/ /" input.txt
Output:
Insert into PE_ATRT_S(ID_ANA_TX,FQ_WQ_ASDF,ID_PRTY,NM_ATHY_TX,SC_RND,QU_DGT_RND) values (99990987868959,null,68,'T59 - % Dsc Itm-2 tax 1 Juris',4,5);
Zoomed output:
(99990987868959,null,68,'T59 - % Dsc Itm-2 tax 1 Juris',4,5);
add a comment |Â
up vote
0
down vote
up vote
0
down vote
Perl showcase:
perl -pe "1 while s/'.*K,(?=.*')/ /" input.txt
Output:
Insert into PE_ATRT_S(ID_ANA_TX,FQ_WQ_ASDF,ID_PRTY,NM_ATHY_TX,SC_RND,QU_DGT_RND) values (99990987868959,null,68,'T59 - % Dsc Itm-2 tax 1 Juris',4,5);
Zoomed output:
(99990987868959,null,68,'T59 - % Dsc Itm-2 tax 1 Juris',4,5);
Perl showcase:
perl -pe "1 while s/'.*K,(?=.*')/ /" input.txt
Output:
Insert into PE_ATRT_S(ID_ANA_TX,FQ_WQ_ASDF,ID_PRTY,NM_ATHY_TX,SC_RND,QU_DGT_RND) values (99990987868959,null,68,'T59 - % Dsc Itm-2 tax 1 Juris',4,5);
Zoomed output:
(99990987868959,null,68,'T59 - % Dsc Itm-2 tax 1 Juris',4,5);
answered 5 hours ago
simlev
550114
550114
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f474357%2fremove-comma-from-a-specific-portion-of-a-long-string%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password