'how to split the strings into first name and last name
The namelist is:
[J. A. Rubiño-Martín, R. Rebolo, M. Aguiar, R. Génova-Santos, F. Gómez-Reñasco, J. M. Herreros, R.J. Hoyland, C. López-Caraballo, A. E. Pelaez Santos, V. Sanchez de la Rosa]
and I need to split it into
[[J. A.], [Rubiño-Martín], [R.], [Rebolo], [M.], [Aguiar], [R.], [Génova-Santos], [F.], [Gómez-Reñasco], [J. M.], [Herreros], [R.J.], [Hoyland], [C.], [López-Caraballo], [A. E.], [Pelaez Santos], [V.], [Sanchez de la Rosa]
using python regex
Solution 1:[1]
For the given input, this regex works. The first group will match any number of tokens followed by a dot, multiple times in greedy fashion. The second group matches everything after the last dot followed by one ore more spaces.
^(.+\.)+\s+(.+)$
https://regex101.com/r/Jxy3Un/1
Here is a visualization:
But as pointed out in the comments, it could easily break if you get names that don't follow this rather strict pattern.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |

