Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #83624
| References | <54B40C85.5000806@emerytelcom.com> |
|---|---|
| Date | 2015-01-13 05:48 +1100 |
| Subject | Re: Python 3 regex? |
| From | Chris Angelico <rosuav@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.17634.1421088499.18130.python-list@python.org> (permalink) |
On Tue, Jan 13, 2015 at 5:03 AM, Jason Bailey <jbailey@emerytelcom.com> wrote:
> Unfortunately, I get no matches. From output on the command line, I can see
> that Python is adding extra backslashes to my re.compile string. I have
> added the raw 'r' in front of the strings to prevent it, but to no avail.
>
Regexes are notoriously hard to debug. Is there any particular reason
you _have_ to use one here? ISTM you could simplify it enormously by
just looking for the opening string:
shared_network = "My-Network-FECO"
network = filebody.split("\nshared-network "+shared_network+"
{",1)[1].split("\n}\n")[0]
Assuming your file is always correctly indented, and assuming you
don't have any other instances of that header string, you should be
fine.
ChrisA
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Python 3 regex? Chris Angelico <rosuav@gmail.com> - 2015-01-13 05:48 +1100
csiph-web