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


Groups > comp.lang.python > #83624

Re: Python 3 regex?

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.002
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'output': 0.05; 'string.': 0.05; 'subject:Python': 0.06; 'assuming': 0.09; 'here?': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'jan': 0.12; "'r'": 0.16; 'backslashes': 0.16; 'fine.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'string:': 0.16; 'prevent': 0.16; 'wrote:': 0.18; 'skip:f 30': 0.19; 'command': 0.22; 'cc:addr:python.org': 0.22; 'skip:{ 20': 0.24; 'string,': 0.24; 'header': 0.24; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'message-id:@mail.gmail.com': 0.30; '13,': 0.31; 'file': 0.32; 'front': 0.32; 'raw': 0.33; 'could': 0.34; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'instances': 0.36; 'subject:?': 0.36; 'should': 0.36; 'jason': 0.38; 'skip:u 10': 0.60; 'line,': 0.68; '2015': 0.84; 'bailey': 0.84; 'to:none': 0.92
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=cZtQbZUDHBLBus18SID/Lwysiu7Zc92r9+zNcY1qKG4=; b=r/OK9CHElXPMO/g6hEtkmARI1BQ6irnYXlucwASsLjCUK1uEOL5Kdj3DZq2oGJcls3 UQQEpAReNsRjrMl+qTv/b7NxnL2bkYDf2DfHjOgtizGEM8rZRecp2YWns22e6U+p2IPU MW0aKCXl43Pd4CSOgICIGCpTNll3FNeEd4yDoHyq84qLc2X1nO+8OytlIJqpF0To6at5 c8d0oBkgfhwwymGOwGZVuf1IXiwXg0ofuUu+ege/xoVqM6UsMgZBkZisG2Tj5T/+9Ct8 YYucpi1S8B4ZB51A16k//fZewJxBzcsKZ8B5iyKUNnX76fHLir7Kvbic0DSNfUJu1jTI OmrA==
MIME-Version 1.0
X-Received by 10.42.95.12 with SMTP id d12mr25066212icn.12.1421088490546; Mon, 12 Jan 2015 10:48:10 -0800 (PST)
In-Reply-To <54B40C85.5000806@emerytelcom.com>
References <54B40C85.5000806@emerytelcom.com>
Date Tue, 13 Jan 2015 05:48:10 +1100
Subject Re: Python 3 regex?
From Chris Angelico <rosuav@gmail.com>
Cc "python-list@python.org" <python-list@python.org>
Content-Type text/plain; charset=UTF-8
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.17634.1421088499.18130.python-list@python.org> (permalink)
Lines 19
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1421088499 news.xs4all.nl 2970 [2001:888:2000:d::a6]:50076
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:83624

Show key headers only | View raw


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


Thread

Re: Python 3 regex? Chris Angelico <rosuav@gmail.com> - 2015-01-13 05:48 +1100

csiph-web