I have a pattern of text that I would like to find and push to a new line. The pattern is ),
followed by a space and a character. Like this -
text_orig =
text cat dog cat dog
),
text rabbit cat dog
), text coffee cat dog. #need to indent this line
where it would become
text_new =
text cat dog cat dog
),
text rabbit cat dog
),
text coffee cat dog
I'm pretty close to a solution, but stuck on what approach to use. Currently, I'm using re.sub
but I believe that removes the first letter of the text like so -
text_new =
text cat dog cat dog
),
text rabbit cat dog
),
ext coffee cat dog # removes first letter
re.sub('\),\s\w','), \n',text_orig)
Would I need search
instead of sub
? Help is very appreciated