0

For example, I have the following text:

'\n1 test1 \ntest1 \n22, test2 \n333 test3 \n444 test4'

I want it to be:

['\n1 test1 \ntest1 ', '\n22, test2 ', '\n333 test3 ', '\n444 test4']

I can use re.findall(r'(\n\d[\s\S]+?(?=\n\d))', d) to find the first three string, but can not get the last string \n444 test4.

I have read Regular expression to match a line that doesn't contain a word, but this is not my case. Is there any easy way to do it? Thanks in advance!

fitz
  • 500
  • 2
  • 9

0 Answers0