I am using regex to split a string <book name> by <author name>
into book and author names.
re.split(r'\bby\b', text, 0, re.I)
But problem arises when the book name contains the word "by" (e.g. Death by Blackhole by Tyson
=> ['Death', 'by Black...']
)
How do I split the string by the last occurrence of the search pattern?
I have a hunch -/+ve look-ahead/behind could be useful here, but currently splitting hairs trying to construct the proper syntax.