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


Groups > comp.lang.python > #35804

Re: ignore case only for a part of the regex?

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 <joel.goldstick@gmail.com>
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; '&gt;': 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 <roy-4F8381.10201930122012@news.panix.com>
References <50e02485$0$3109$ba620e4c@news.skynet.be> <roy-4F8381.10201930122012@news.panix.com>
Date Sun, 30 Dec 2012 10:41:57 -0500
Subject Re: ignore case only for a part of the regex?
From Joel Goldstick <joel.goldstick@gmail.com>
Cc "python-list@python.org" <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 <python-list.python.org>
List-Unsubscribe <http://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 <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1465.1356882119.29569.python-list@python.org> (permalink)
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

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

On Sun, Dec 30, 2012 at 10:20 AM, Roy Smith <roy@panix.com> wrote:

> Helmut Jarausch <jarausch@skynet.be> 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

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

re: ignore case only for a part of the regex? Helmut Jarausch <jarausch@skynet.be> - 2012-12-30 11:24 +0000
  Re: ignore case only for a part of the regex? Roy Smith <roy@panix.com> - 2012-12-30 10:20 -0500
    Re: ignore case only for a part of the regex? Joel Goldstick <joel.goldstick@gmail.com> - 2012-12-30 10:41 -0500
    Re: ignore case only for a part of the regex? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-01-01 04:14 +0000
      Re: ignore case only for a part of the regex? Vlastimil Brom <vlastimil.brom@gmail.com> - 2013-01-02 00:09 +0100
        Re: ignore case only for a part of the regex? wxjmfauth@gmail.com - 2013-01-02 06:17 -0800
        Re: ignore case only for a part of the regex? wxjmfauth@gmail.com - 2013-01-02 06:17 -0800
  Re: ignore case only for a part of the regex? Vlastimil Brom <vlastimil.brom@gmail.com> - 2012-12-30 17:38 +0100
    Re: ignore case only for a part of the regex? Roy Smith <roy@panix.com> - 2012-12-30 12:32 -0500
      Re: ignore case only for a part of the regex? MRAB <python@mrabarnett.plus.com> - 2012-12-30 18:04 +0000
      Re: ignore case only for a part of the regex? Cameron Simpson <cs@zip.com.au> - 2012-12-31 11:29 +1100

csiph-web