I
I
IlyaPrivolnov3332022-02-25 13:51:46
Regular Expressions
IlyaPrivolnov333, 2022-02-25 13:51:46

How to write a regular expression to select every fourth coordinate?

Given the coordinates of the city:

[65.051193, 35.314801] [65.127703, 35.29793], [65.184477, 35.346113] [65.220663, 35.435205] [65.252509, 35.612738] [65.278715, 35.955825] [65.278063, 36.031102] [65.267529, 36.100086] [65.244672 , 36.165725] [65.250549, 36.279774] [65.241681, 36.358604] [65.216342, 36.43206], [65.181336, 36.473356] [65.139086, 36.476838] [65.103086, 36.438112] [65.065371, 36.318248] [65.052352, 36.229193 ] [64.97854, 36.2276] [64.933542, 36.170912] [64.914537, 36.103882] [64.90965, 35.982465] [64.877042, 35.851886] [64.867921, 35.778449] [64.837907, 35.806084] [64.803037, 35.806064] [64.771271, 35.775214] [64.746388, 35.716157] [64.757677, 35.673386] [64.836913, 35.634839] [65.011804, 35.469228] [63.580076, 35.897179] [63.626957, 36.456205] [63.748226, 36.590402] [63.956503 , 36.555591], [64.278274, 36.877611], [64.316933, 37.015157],[64.625588, 36.568498], etc.

We will assume that the record of the form - "[64.316933, 37.015157]," is one coordinate. You must use the regular expression to identify and remove every fourth coordinate

Example:
[65.051193, 35.314801] [65.127703, 35.29793] [65.184477, 35.346113] [65.220663, 35.435205] [65.252509, 35.612738] [65.278715, 35.955825], [ 65.278063, 36.031102] [65.267529, 36.100086] [65.244672, 36.165725] [65.250549, 36.279774] [65.241681, 36.358604] [65.216342, 36.43206] [65.181336, 36.473356] ... In the end, all that is inside tags should be highlighted and removed. The task is complicated by the fact that all coordinates are of the same type. Please let me know if there is a possible solution for this problem.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stalker_RED, 2022-02-25
@Stalker_RED

Skip three repetitions of closing brackets with a semicolon, capture the next brackets.
More or less like this.
https://regex101.com/r/ElsCT1/1
It's hard to debug from the phone, and my ISP's fiber was blown up (

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question