Try with following regex:
(\d+\.\d+),(\d+\.\d+)
and replace it with:
\2,\1
Domanda
i'm trying to swap latitude and longitude values in notepad++ with regular expressions. i tried to search some guide on the web but i didn't understand how to do. i have a file in which there are: "longitude,latitude" and i want to get: "latitude,longitude" in each row
Example (with two rows):
12.5164654350527,41.8919188281474
12.5164650441393,41.891919097598
becomes
41.8919188281474,12.5164654350527
41.891919097598,12.5164650441393
Which regular expression do i have to use?
Soluzione
Try with following regex:
(\d+\.\d+),(\d+\.\d+)
and replace it with:
\2,\1
Altri suggerimenti
Search for:
([0-9]+(\.[0-9]+)?),([0-9]+(\.[0-9]+)?)
Replace with:
\2,\1
This catches numbers like 1
, 1.1
but not 1.
or .5
. My previous regexp ([0-9]+.?[0-9]*),([0-9]+.?[0-9]*)
would allow for 1.
.
Make sure you place the cursor at the beginning of the file.
CTRL+H
.Replace
tab.Select Regular Expression
at the bottom.
Find: ([\d.]+),([\d.]+)
Replace: \2,\1
find what:
^([0-9]*\.[0-9]*),([0-9]*\.[0-9]*)$
replace with:
\2,\1
also, search mode should be set to regular expression
edit: escaped .
as suggested in comments.