我有一个巨大的文件,字符串看起来像这样:
ABS; Ba; Accountant / Belastingconsulent;Nederlands;2001/04/03;2001/04/03;Hollestraat 32a 9450 HAALTERT;straat xxa;9450;HALTER;+32 (53) 12.34.56;+32 (53) 12.34.56;;Beekstraat 67/1 9300 AALST;Beekstraat 67/1;9300;AALST;+32 (53) 12.34.56;+32 (53) 12.34.56;+32 (474) 12.34.56;;
1;emailaddr@email.com; deepurllink;
数字字段现在采用不可用的格式:
;+32 (53) 12.34.56;+32 (53) 12.34.56;;Somestraat 67/1 9300 AALST;Somestraat 67/1;9300;AALST;+32 (53) 12.34.56;+32 (53) 12.34.56;+32 (474) 12.34.56;;
我至少需要找到手机号码并将其格式化为:
;+32 (474) 12.34.56;
自
;+32474123456;
如果有人可以建议一个 reg expr 来查找并替换它,我将不胜感激。
我不想猜测..这里有一些信息可以帮助你:
正则表达式:/;(+[0-9]{2}) (([0-9]{2,3})) ([0-9]{2}).([0-9]{2}).([0-9]{2})/g
图案:;(+[0-9]{2}) (([0-9]{2,3})) ([0-9]{2}).([0-9]{2}).([0-9]{2})
替换为:;$1$2$3$4$5
在这里,我们捕获5组:
group 1: (+[0-9]{2})
group 2: ([0-9]{2})
group 3: ([0-9]{2})
group 4: ([0-9]{2})
group 5: ([0-9]{2})
输入:
ABS; Ba; Accountant / Belastingconsulent;Nederlands;2001/04/03;2001/04/03;Hollestraat 32a 9450 HAALTERT;straat xxa;9450;HALTER;+32 (53) 12.34.56;+32 (53) 12.34.56;;Beekstraat 67/1 9300 AALST;Beekstraat 67/1;9300;AALST;+32 (53) 12.34.56;+32 (53) 12.34.56;+32 (474) 12.34.56;;1;emailaddr@email.com; deepurllink
输出:
ABS; Ba; Accountant / Belastingconsulent;Nederlands;2001/04/03;2001/04/03;Hollestraat 32a 9450 HAALTERT;straat xxa;9450;HALTER;+3253123456;+3253123456;;Beekstraat 67/1 9300 AALST;Beekstraat 67/1;9300;AALST;+3253123456;+3253123456;+32474123456;;1;emailaddr@email.com; deepurllink
;+32 (474) 12.34.56;
成为;+32474123456;
,请找到/[.() ]/g
并替换为任何内容。