I have a long text, which should be splitted into some sections, where all sections have a pattern like following with different KEY. And the /n/r can not be used to split
I don't know whether this can be done easily, for example by using RE module [demo text starts] a line we do not need I am section axax I am section bbb, we can find that the first 2 lines of this section all startswith 'I am section' .....(and here goes many other text)... let's continue to let's continue, yeah .....(and here goes many other text)... I am using python I am using perl .....(and here goes many other text)... [demo text ends] the above text should be splitted as a LIST with 3 items, and I also need to know the KEY for LIST is ['I am section', 'let's continue', 'I am using']: lst=[ '''I am section axax I am section bbb, we can find that the first 2 lines of this section all startswith 'I am section' .....(and here goes many other text)...''', '''let's continue to let's continue, yeah .....(and here goes many other text)...''', '''I am using python I am using perl .....(and here goes many other text)...''' ] I hope I have state myself clear. Regards
-- https://mail.python.org/mailman/listinfo/python-list