Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #57767
| From | "Marc" <marc@marcd.org> |
|---|---|
| Subject | Parsing multiple lines from text file using regex |
| Date | 2013-10-27 17:09 -0400 |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1665.1382911575.18130.python-list@python.org> (permalink) |
[Multipart message — attachments visible in raw view] - view raw
Hi, I am having an issue with something that would seem to have an easy solution, but which 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
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
Parsing multiple lines from text file using regex "Marc" <marc@marcd.org> - 2013-10-27 17:09 -0400
Re: Parsing multiple lines from text file using regex "Rhodri James" <rhodri@wildebst.demon.co.uk> - 2013-10-27 22:19 +0000
Re: Parsing multiple lines from text file using regex Roy Smith <roy@panix.com> - 2013-10-27 18:43 -0400
Re: Parsing multiple lines from text file using regex Ben Finney <ben+python@benfinney.id.au> - 2013-10-28 10:34 +1100
csiph-web