In my NLP pipeline, I need to split titles from body text. Titles always consist of a sequence of capitalized words without any punctuation. The titles are separated from the body text using two whitespace characters \n\n.
For example:
This Is A Title
This is where the body starts.
I want to split the title and body text on the whitespace using Regex in Python, such that the result is: This Is A Title, This is where the body starts.
Can anybody help me to write the right Regex? I tried the following:
r'(?<=[A-Z][a-z]+)\n\n(?=[A-Z])'
but then I got the error that lookbehinds only work with strings of fixed length (but they should be allowed to be variable). Note that I cannot use r'\n\n' because line separators also occur in the body text (so this would result in too many splits).
Many thanks for helping me out!