In article <mailman.9492.1398431281.18130.python-l...@python.org>,
 oyster <lepto.pyt...@gmail.com> wrote:

> 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]

This kind of looks like a standard INI file.  Check out 
https://docs.python.org/2/library/configparser.html, it may do what you 
need.
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to