I have a column in a postgresql table with strings that contain the magnitude level of an historical list of earthquakes and I need to extract only the number in a separate column. All values have the following pattern:
[Charater "M" or "Md"][space][magnitude level number][" - "][timestamp]
I need to extract only the number but I'm not able to write a specific regular expression to do that, can you help me ? Thanks in advance
─────────────────────────────────── ─────────────────
| Start column | Desired output |
─────────────────────────────────── ─────────────────
| Md 2.7 - 1985-04-18 20:18:02 UTC | 2.7 |
| M 2.4 - 1985-04-18 17:49:13 UTC | 2.4 |
─────────────────────────────────── ─────────────────
CodePudding user response:
https://regex101.com/r/bMnF3k/1
If think this can work
(?<= )(?:\b\d\.\d\b|\b\d\d\b|\b\d\b)(?= )