# coding=utf8
# the above tag defines encoding for this document and is for Python 2.x compatibility
import re
regex = r"((?P<fname>[A-Za-zåé]+ ?[A-Za-zåé]+\.? ?)+ (?P<lname>[A-Za-zåé]+\.? ?))(?:(?:\d+,)+ ?)?"
test_str = "Frank Kreienkamp1, Sjoukje Y. Philip2, Jordis S. Tradowsky1,4, Sarah F. Kew2, Philip Lorenz1, Julie Arrighi7,8,9, Alexandre Belleflamme16, Thomas Bettmann18, Steven Caluwaerts13,19, Steven C. Chan14, Andrew Ciavarella22, Lesley De Cruz13, Hylke de Vries2, Norbert Demuth18, Andrew Ferrone17, Erich M. Fischer6, Hayley J. Fowler14, Klaus Goergen16, Dorothy Heinrich7, Yvonne Henrichs18, Geert Lenderink2, Frank Kaspar10, Enno Nilson15, Friederike E L Otto11, Francesco Ragone13,20, Sonia I. Seneviratne6, Roop K. Singh7, Amalie Skålevåg1, Piet Termonia13,19, Lisa Thalheimer11, Maarten van Aalst7,8,21, Joris Van den ergh13, Hans Van de Vyver13, Stéphane Vannitsem13, Geert Jan van Oldenborgh2,3, Bert Van Schaeybroeck13, Robert Vautard5, Demi Vonk8, Niko Wanders"
subst = "\\g<1>\\n"
# You can manually specify the number of replacements by changing the 4th argument
result = re.sub(regex, subst, test_str, 0, re.MULTILINE)
if result:
print (result)
# Note: for Python 2.7 compatibility, use ur"" to prefix the regex and u"" to prefix the test string and substitution.
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Python, please visit: https://docs.python.org/3/library/re.html