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?

References <50e02485$0$3109$ba620e4c@news.skynet.be> <roy-4F8381.10201930122012@news.panix.com>
Date 2012-12-30 10:41 -0500
Subject Re: ignore case only for a part of the regex?
From Joel Goldstick <joel.goldstick@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.1465.1356882119.29569.python-list@python.org> (permalink)

Show all headers | 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