I have a file with some data in this form:
Prefix text: First Name, Second Name, Third--
The prefix differs by line. The number of names varies from one to several. The suffix (--
in the example) is optional and non-alphabetic. I need to expand the comma-separated list of names into multiple lines (easy: s/,/\n/g
), but in such a way that prefix and suffix (if present) surround each of the new entries:
Prefix text: First name--
Prefix text: Second name--
Prefix text: Third--
Instead of banging out a too-long python script, I thought it'd be more fun to ask if someone here can think of the perfect one-liner. Any ideas?