4
I have a certain string below, as you can see, are coordinates separated only by a space. See:
-23.5209 -46.46466 -23.52008 -46.465952 -23.519253 -46.467239 -23.518808 -46.466901 -23.518738 -46.466848 -23.518411 -46.466597 -23.518349 -46.46658 -23.51834 -46.46657 -23.517974 -46.466157 -23.517879 -46.466052 -23.517859 -46.466074 -23.51733 -46.466632 -23.516765 -46.467217 -23.516693 -46.467292 -23.516206 -46.467802 -23.516169 -46.467841 -23.516179 -46.467859 -23.516229 -46.467909 -23.516329 -46.467981 -23.518096 -46.469056
Basically the first item is latitude, second is longitude and so on. I need it to stay this way below, which is the separation between latitude and longitude by comma, and between coordinate by pipe. See:
-23.5209,-46.46466|-23.52008,-46.465952|-23.519253,-46.467239|-23.518808,-46.466901|-23.518738,-46.466848 ...
What better way to do it?
From what I understand, the last coordinate does not fit the regex. If you remove the
\s
of the end ai yes it works. Think you can influence removing?! What the\s
does exactly!?– viana
@acklay
\s
is a meta character ofmatch espaços
; maybe\s?
to make optional match?– Jefferson Quesado
@Jeffersonquesado did not understand if you are telling me something or if you are asking a question. xD
– viana
@acklay I’ll rewrite. 1)
\s
house any and all space, as\d
box digits; 2)\s?
makes the presence of spacing optional, can solve the problem of the last coordinate– Jefferson Quesado