0

Help

How to move the initials after surname beforehand in the string Authors: Komeili A. Cali H. Beveridge T. J. and Newman D. K.???

20th Nov 2017, 5:00 PM
Ilya Grib
Ilya  Grib - avatar
3 Answers
0
need more information to help you. so you wanna change the string from "Authors: Komeili A. Cali H. Beveridge T. J. and Newman D. K." into what?
20th Nov 2017, 9:52 PM
Lindsay Linjie Chen
Lindsay Linjie Chen - avatar
0
Into "Authors: A. Komeili H. Cali T. Beveridge..
21st Nov 2017, 4:19 AM
Ilya Grib
Ilya  Grib - avatar
0
Try this in Python :) #Authors: Komeili A. Cali H. Beveridge T. J. and Newman D. K. import re authors = 'Authors: Komeili A. Cali H. Beveridge T. J. and Newman D. K.' pattern = r"(\w+)\s+((\w+\.(\s)*)+)" matchs = re.findall(pattern, authors) if matchs: firstmatch = re.search(pattern, authors).start() result = authors[:firstmatch] print(firstmatch) for match in matchs: result += '{givenname} {surname} '.format(surname=match[0].strip(), givenname = match[1].strip()) print(result)
23rd Nov 2017, 10:06 AM
Lindsay Linjie Chen
Lindsay Linjie Chen - avatar