想用替换命令替换猪拉丁语中的\

时间:2015-09-30 01:23:04

标签: apache-pig

我有一个文件,其数据如下所示

<"{\"action\": \"ac_data\",\"data\":{\"nn1\":\"0000000\",\"zerosquare\":\"newuser\",\"nacde\":\"catlogue\",\"user123\":\"99000200340904\",\"lcadq\":\"89148000001972298094\",\"reserve\":\

我想删除\,输出应该如下

<"{"action": "ac_data","data":{"nn1":"0000000","zerosquare":"newuser","nacde":"catlogue","user123":"99000200340904","lcadq":"89148000001972298094","reserve":

1 个答案:

答案 0 :(得分:0)

输入:

<"{\"action\": \"ac_data\",\"data\":{\"nn1\":\"0000000\",\"zerosquare\":\"newuser\",\"nacde\":\"catlogue\",\"user123\":\"99000200340904\",\"lcadq\":\"89148000001972298094\",\"reserve\":\

猪脚本:

A = LOAD 'input.csv' as line;  
B = FOREACH A GENERATE REPLACE(line,'([\\\\]+)','');  
dump B;  

输出

(<"{"action": "ac_data","data":{"nn1":"0000000","zerosquare":"newuser","nacde":"catlogue","user123":"99000200340904","lcadq":"89148000001972298094","reserve":)

参考:

Can't escape the backslash with regex?