Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #57770 > unrolled thread

Re: Parsing multiple lines from text file using regex

Started byMark Lawrence <breamoreboy@yahoo.co.uk>
First post2013-10-27 22:26 +0000
Last post2013-10-27 22:26 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Parsing multiple lines from text file using regex Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-10-27 22:26 +0000

#57770 — Re: Parsing multiple lines from text file using regex

FromMark Lawrence <breamoreboy@yahoo.co.uk>
Date2013-10-27 22:26 +0000
SubjectRe: Parsing multiple lines from text file using regex
Message-ID<mailman.1667.1382912780.18130.python-list@python.org>
On 27/10/2013 21:09, Marc wrote:
> Hi,
> I am having an issue with something that would seemtohave an easy
> solution,butwhich escapes me.  I have configuration files that I would
> like to parse.  The data I am having issue with is a multi-line
> attribute that has the following structure:
>
> banner <option> <banner text delimiter>
> Banner text
> Banner text
> Banner text
> ...
> <banner text delimiter>
>
> The regex 'banner\s+(\w+)\s+(.+)' captures the command nicely and
> banner.group(2) captures the delimiter nicely.
>
> My issue is that I need to capture the lines between the delimiters
> (both delimiters are the same).
>
> I have tried various permutations of
>
> Delimiter=banner.group(2)
> re.findall(Delimiter'(.*?)'Delimiter, line, re.DOTALL|re.MULTILINE)
>
> with no luck
>
> Examples I have found online all assume that the starting and ending
> delimiters are different and are defined directly in re.findall().  I
> would like to use the original regex extracting the banner.group(2),
> since it is already done, if possible.
>
>
> Any help in pointing me in the right direction would be most appreciated.
>
> Thank you,
>
> Marc
>

What was wrong with the answer Peter Otten gave you earlier today on the 
tutor mailing list?

-- 
Python is the second best programming language in the world.
But the best has yet to be invented.  Christian Tismer

Mark Lawrence

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web