On Tue, Jan 13, 2015 at 5:03 AM, Jason Bailey <jbai...@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 -- https://mail.python.org/mailman/listinfo/python-list