我有一个场景,我们希望将数据之间的多个双引号替换为单引号,但由于输入数据用"comma"
分隔符分隔,所有列数据都用双引号括起来,""
遇到了问题,解释如下:
示例数据如下所示:
"int","","123","abd"""sf123","top"
因此,输出将是:
"int","","123","abd"sf123","top"
已尝试以下方法以获得解决方案,但只有第一次出现才起作用,不确定问题是什么??
sed -ie 's/,"",/,"NULL",/g;s/""/"/g;s/,"NULL",/,"",/g' inputfile.txt
1.将所有->From,“”,替换为“Null”,
1.将->的所有多次出现从“”或“”或“”改为“”(单次出现)
1.将1步更改替换回原始->From,“Null”,To,“”,
但是,只有第一个示例正在更改,其余的内容如下所示:
如果输入为:
"int","","","123","abd"""sf123","top"
输出结果如下:
"int","","NULL","123","abd"sf123","top"
但是,输出应该是:
"int","","","123","abd"sf123","top"
1条答案
按热度按时间oogrdqng1#
您可以尝试这款
perl
,但要提前看一下:其中,输入为:
分手:
("")+
:匹配1+对双引号(?=")
:如果这些对后面跟一个"