I have a .txt file containing:
Country,City,AccentCity,Region,Population,Latitude,Longitude
.. for all cities in the world (3.000.000+ cities). Link to file here.
I want to use the RegEx replace functionality in Notepad++ to change the list, so that the output will be as follows:
AccentCity,Country
The "Country" data should be capitalized. Here is an exmaple:
Example before and after RegEx
ad,aixas,Aixàs,06,,42.4833333,1.4666667
ad,aixirivali,Aixirivali,06,,42.4666667,1.5
ad,aixirivall,Aixirivall,06,,42.4666667,1.5
ad,aixirvall,Aixirvall,06,,42.4666667,1.5
ad,aixovall,Aixovall,06,,42.4666667,1.4833333
dk,ebeltoft,Ebeltoft,18,5888,56.201801,10.682258
.......
Aixàs,AD
Aixirivali,AD
Aixirivall,AD
Aixirvall,AD
Aixovall,AD
Ebeltoft,DK
I am new to RegEx and i can't seem to be getting it right. I hope someone can help me.
Best regards, Anton
答案 0 :(得分:3)
Find:
^([^,]+),[^,]+,([^,]+).*
Replace with:
$2,\U$1
Find is as straightforward as it could be - line start, find non-comma characters in group 1, comma, non-comma chars, comma, non-comma characters in group 2, rest of the line. Assumes all the comma separated groups up to AccentCity are always filled with at least one character.
replace changing the order, and adding \U to capitalize group 1.