如何将某些字符串更改为其他形式?

时间:2014-02-06 10:47:11

标签: regex notepad++ removing-whitespace

我有一些看起来像的字符串:

string1 string2 number1 number2 string3

需要将其更改为: string1 string2,number1,number2(没有string3)

或:

string1 number1 number2 string2>> string1,number1,number2(没有string2)

我使用(\D*\s|\-\D*)\s*(\d{2}.\d{3})\s*(\d{2}.\d{3})(\D)查找匹配的字符串,使用$1,$2,$3;获取最终表单,但未成功。

在字符串中:

 Aleksandrów Kujawski 52.880  18.700  Kujawsko-Pomorskie 
 Aleksandrów Łódzki 51.820  19.299  Łódzkie 
 Andrychów 49.860  19.339  Małopolskie 
 Augustów 53.839  23.000  Podlaskie 

将其更改为:

 Aleksandrów Kujawski ,52.880,18.700; Kujawsko-Pomorskie 
 Aleksandrów Łódzki ,51.820,19.299; Łódzkie 
 Andrychów ,49.860,19.339; Małopolskie 
 Augustów ,53.839,23.000; Podlaskie 

应该是什么样的:

Aleksandrów Kujawski,52.880,18.700;
Aleksandrów Łódzki,51.820,19.299;
Andrychów,49.860,19.339;
Augustów,53.839,23.000;

任何提示?

1 个答案:

答案 0 :(得分:0)

你可以用记事本++:

Fin what:^(\s*\S+(?:\s+\D+)?)\s+(\S+)\s+(\S+).*
替换为:$1,$2,$3;