0

I would like extract all 4 fields. Please help me

here is database structure :

[12.345,-12.34567,"title 34","12345"],[-12.987,12.765,"title 36","7689"]

12.345 = latitude data with number and point and dash
-12.34567 = longitude data with number and point and dash
title 34 = text with space and number
12345 = number id with number

I would like to get this result

1 = 12.345
2 = -12.34567
3 = title 34
4 = 12345

I have tested many solutions but without success this example helped me to take a first step but not completely Regular expression to extract text between square brackets

thanks a lot for your response :-)

  • What have you searched for, and what did you find? What have you tried, and how did it fail? – tripleee Dec 17 '19 at 17:58
  • Also , which programming language are you using? – Badro Niaimi Dec 17 '19 at 17:59
  • Also, please read the [`regex` tag info page](/tags/regex/info); it shows how to ask a proper question with enough details. – tripleee Dec 17 '19 at 17:59
  • Is your input a string or an array? We need to know the language. Are escaped quotes withing quotes possible: `"my \"string\""`? – ctwheels Dec 17 '19 at 18:01
  • Umm, use a JSON parser. – MonkeyZeus Dec 17 '19 at 19:20
  • `1,2,3,4` Regex can't count. There is a linear database structure line followed by some free text vertical block, followed by another vertical block with sequential numbers. Can this sample text be pared down to show just whats needed ? –  Dec 17 '19 at 20:06

1 Answers1

-1

Try this: \[(?'lat'[-.0-9]+),(?'long'[-.0-9]+),\"(?'text'[^\"]+)\",\"(?'id'\d+)\"\] The result is grouped by name.

Here's the link showing the example: https://regex101.com/r/YNv8qr/1

Joseph Lee
  • 2,838
  • 16
  • 25
  • For my understanding, why is this marked as a bad answer? The link would demonstrate that it extracted the fields correctly. – Joseph Lee Dec 18 '19 at 02:26
  • Thank you Joseph it works perfectly and that's exactly what I need. Thank you very much for this solution – Nicolas Porta Dec 18 '19 at 18:27