Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.026 X-Spam-Evidence: '*H*': 0.95; '*S*': 0.00; 'lines,': 0.05; 'python': 0.09; 'subject:ignore': 0.09; 'cc:addr:python-list': 0.10; 'dec': 0.15; 'regex,': 0.16; 'roy': 0.16; 'subject:case': 0.16; "\xc2\xa0i'm": 0.16; 'string': 0.17; 'wrote:': 0.17; 'specify': 0.17; 'comfortable': 0.20; 'trying': 0.21; 'of.': 0.22; 'cc:2**0': 0.23; 'programming': 0.23; '>': 0.23; 'matching': 0.23; 'split': 0.23; "i've": 0.23; 'seems': 0.23; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'am,': 0.27; 'message- id:@mail.gmail.com': 0.27; 'this?': 0.28; 'received:209.85.212': 0.28; 'enforce': 0.29; 'header,': 0.29; 'methods.': 0.29; 'piece': 0.29; 'url:mailman': 0.29; 'skip:& 10': 0.29; "i'm": 0.29; "skip:' 10": 0.30; 'code': 0.31; 'url:python': 0.32; 'not.': 0.32; 'url:listinfo': 0.32; 'curious': 0.33; 'typically': 0.33; 'received:google.com': 0.34; 'text': 0.34; 'doing': 0.35; 'subject:?': 0.35; 'received:209.85': 0.35; 'something': 0.35; 'there': 0.35; 'really': 0.36; 'but': 0.36; 'url:org': 0.36; 'should': 0.36; 'received:209': 0.37; 'subject:: ': 0.38; 'comment': 0.38; 'easier': 0.38; 'apply': 0.39; 'takes': 0.39; 'build': 0.39; 'where': 0.40; 'header:Received:5': 0.40; 'url:mail': 0.40; 'think': 0.40; 'your': 0.60; 'lower': 0.61; 'first': 0.61; '30,': 0.62; 'between': 0.63; 'more': 0.63; 'grab': 0.64; 'learned': 0.65; 'smith': 0.71; 'sensitivity': 0.84; 'joel': 0.91; 'to:none': 0.93 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=Jq8XGyGrpDcT5s8Gldwv9jn0/0rRAPSYQzbeX2FCGZY=; b=x+LkUS29uY+L9DIIuGgVyFb9o4GWRUbeXGuDSI4pxNkbhFyS6OZdYvQtEzel8InTX5 ouke1wOdcTSB0SPwml2HGwznI/ShpCWBBKt81PUFIDpAX6BaieUcQVA/qYb3HYu5yd6e tIhFP3KhyZdoLsMnff9cwie6tkYM21HhBc4QYz9kJCAOGsZcc53gucOdoHAH2ULEwZyn mPcbm8dnwb5kewm4hLqovCxGp8aLrv3Pk977f8XichVi5X4ODrtfDbNRYxoURzhRGANl OhOzIWsTr02WX8/tgO4Zql0FGKvl609/5Fqa/l42QgaBl4zZ8e8qhXlvwWSkuWGLBrJU lCgg== MIME-Version: 1.0 In-Reply-To: References: <50e02485$0$3109$ba620e4c@news.skynet.be> Date: Sun, 30 Dec 2012 10:41:57 -0500 Subject: Re: ignore case only for a part of the regex? From: Joel Goldstick Cc: "python-list@python.org" Content-Type: multipart/alternative; boundary=089e010d83389b018404d213bc2f X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 98 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1356882119 news.xs4all.nl 6950 [2001:888:2000:d::a6]:51541 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:35804 --089e010d83389b018404d213bc2f Content-Type: text/plain; charset=UTF-8 On Sun, Dec 30, 2012 at 10:20 AM, Roy Smith wrote: > Helmut Jarausch wrote: > > > is there a means to specify that 'ignore-case' should only apply to a > part > > of a regex? > Python has excellent string methods. There seems to be a split between people who first always grab regex for string parsing, and those who might not. If you go with your regex, I think you can comment what you have and move on. I glaze over looking at regexes. That's just me. The code to first search for "Msg-", then check what follows would take a couple of lines, but might be easier to understand later. I've been writing python for a couple of years, and although I feel comfortable with it, there is much more more me to learn. One thing I have learned over many years of programming is that figuring out what a piece of code is trying to accomplish takes more time than writing it originally. Do you really want to match "Msg-iD" (lower case i)? Or are you only allowing "ID" or "Id"? > > Not that I'm aware of. > > > the regex should match Msg-id:, Msg-Id, ... but not msg-id: and so on. > > What's the use-case for this? > > The way I would typically do something like this is build my regexes in > all lower case and .lower() the text I was matching against them. I'm > curious what you're doing where you want to enforce case sensitivity in > one part of a header, but not in another. > -- > http://mail.python.org/mailman/listinfo/python-list > -- Joel Goldstick --089e010d83389b018404d213bc2f Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable



On Sun, Dec 30, 2012 at 10:20 AM, Roy Smith <<= a href=3D"mailto:roy@panix.com" target=3D"_blank">roy@panix.com> wrote:
Helmut Jarausch <jarausch@skynet.be> wrote:

> is there a means to specify that 'ignore-case' should only app= ly to a part
> of a regex?

Python has excel= lent string methods.=C2=A0 There seems to be a split between people who fir= st always grab regex for string parsing, and those who=C2=A0 might not.=C2= =A0 If you go with your regex, I think you can comment what you have and mo= ve on.=C2=A0 I glaze over looking at regexes.=C2=A0 That's just me. The= code to first search for "Msg-", then check what follows would t= ake a couple of lines, but might be easier to understand later.=C2=A0 I'= ;ve been writing python for a couple of years, and although I feel comforta= ble with it, there is much more more me to learn.=C2=A0 One thing I have le= arned over many years of programming is that figuring out what a piece of c= ode is trying to accomplish takes more time than writing it originally.

Do you really want to match "Msg-iD" (lower case i= )? Or are you only allowing "ID" or "Id"?

Not that I'm aware of.

> the regex should match =C2=A0Msg-id:, Msg-Id, ... =C2=A0but not =C2=A0= msg-id: and so on.

What's the use-case for this?

The way I would typically do something like this is build my regexes in
all lower case and .lower() the text I was matching against them. =C2=A0I&#= 39;m
curious what you're doing where you want to enforce case sensitivity in=
one part of a header, but not in another.
--
http://mail.python.org/mailman/listinfo/python-list



--
Joel Gold= stick
--089e010d83389b018404d213bc2f--