在每个“|”实例之前删除7个(任何变体的)数字

时间:2011-08-25 12:29:47

标签: regex

我有大量文件(1700万行),其中包含以下格式的内容:

"AB101XG","57.144165160000000|","-2.114847768000000|";
"AB106RN","57.137879760000000|","-2.121486688000000|";
"AB107JB","57.124273770000000|","-2.127189644000000|";
"AB115QN","57.142701090000000|","-2.093014619000000|";
"AB116UL","57.137546630000000|","-2.112695886000000|";
"AB118RQ","57.135977620000000|","-2.072114784000000|";
"AB123FJ","57.098002900000000|","-2.077668775000000|";
....

减小尺寸,因为不需要我想在每个|之前删除最后7个数字不应删除其他数字等。

任何想法,如果有所作为,我正在使用Textpad

谢谢,Neil

3 个答案:

答案 0 :(得分:3)

您可以搜索[0-9]{7}\|并将其替换为|

查看TextPad Quick Reference Card以获取有关Textpad中正则表达式语法的参考。

答案 1 :(得分:1)

[0-9] {7} \ | ...你必须指定符号yo正在寻找的withink suqare括号,并在花括号内指出你正在寻找的实例连续数...

在你用|

替换所有人之后

答案 2 :(得分:0)

用于说明所需模式的Javascript示例。

var line = '"AB101XG","57.144165160000000|","-2.114847768000000|';

var result = line.replace(/\d{7}\|/, '|');

result ; //# =>  "AB101XG","57.14416516|","-2.114847768000000|

仅匹配前7位数后跟|