Sample Text:
SUBJECT = 'NETHERLANDS MUSIC EPA'
CONTENT = 'Michael Buble performs in Amsterdam Canadian singer Michael Buble performs during a concert in Amsterdam, The Netherlands, 30 October 2009. Buble released his new album entitled 'Crazy Love'. EPA/OLAF KRAAK '
Expected result:
"
NETHERLANDS MUSIC EPA | 36 before
Michael Buble performs in Amsterdam Canadian singer Michael Buble performs during a concert in Amsterdam, The Netherlands, 30 October 2009. Buble released his new album entitled 'Crazy Love'. EPA/OLAF KRAAK
"
How can I accomplish this in Python?
Looks like you want something like…:
which does emit, as you require,
Or maybe you want to do the reverse (as a comment suggested)? then they key RE could be
and you can use this similarly to get a match-object, extract subject and content as its groups, and format them for display as you wish.
In either case it’s possible that you may need tweaks — since you haven’t given precise specs, just one single example!, it’s hard to generalize reliably.