Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #39672
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder7.xlned.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <vlastimil.brom@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.001 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'url:pypi': 0.03; 'case.': 0.05; 'ascii': 0.07; 'expressions': 0.07; 'matches': 0.07; '"work': 0.09; 'here?': 0.09; 'cc:addr:python-list': 0.10; '(the': 0.15; 'folks,': 0.16; 'insensitive': 0.16; 'subject:case': 0.16; 'subject:handling': 0.16; 'subject:unicode': 0.16; 'unicode.': 0.16; 'comparing': 0.17; '>>>': 0.18; 'module': 0.19; 'ideal': 0.20; 'addition,': 0.21; 'received:209.85.216.46': 0.21; 'supposed': 0.21; "i'd": 0.22; 'cc:2**0': 0.23; 'work.': 0.23; "python's": 0.23; 'seems': 0.23; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'thoughts': 0.27; 'message- id:@mail.gmail.com': 0.27; 'regular': 0.27; "doesn't": 0.28; 'correct': 0.28; 'url:mailman': 0.29; "i'm": 0.29; 'figure': 0.30; 'url:python': 0.32; 'generally': 0.32; 'url:listinfo': 0.32; 'right?': 0.33; 'hi,': 0.33; 'that,': 0.34; 'received:google.com': 0.34; 'received:209.85': 0.35; 'really': 0.36; 'url:org': 0.36; 'compare': 0.36; 'should': 0.36; 'does': 0.37; 'received:209': 0.37; 'received:209.85.216': 0.37; 'subject:: ': 0.38; 'things': 0.38; 'instead': 0.39; 'url:mail': 0.40; 'skip:u 10': 0.60; 'ever': 0.63; 'hear': 0.63; 'more': 0.63; 'behavior': 0.64; 'improvements': 0.65; 'treat': 0.65; 'manner': 0.74; 'dear!': 0.93 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:cc:content-type:content-transfer-encoding; bh=cqGuPK7MJ2c4CjvXeLNlcUL7J0LFNXYtGSUMfafsFsY=; b=Z8GkmkAHZv05lvuU/UXWEHpl0sx04nxd5J5Hd+6OZIyRSLhygCVUO7BfN2Yh9m/tHk 33cltU8O947Uw3yukpHJucyFWSK2Og+l1y71sgQJgZDCUsbfNzK20kUBEdb5B1Qacrs8 p0UFXRwCQe+YRetZWHhGrXnpS/72TZbkDPgZrmVjh5zV2ZZhU+amqZ0UW55K+FwUuJBj oijoq3Q87lwQT7AhXV8MwnHJnM0GtMfBRKM2AegVxQUTSLwBNKOS9q953034I0xlaAuJ bH/bDaseZLQjUe9/PsjPL5TgNzsxYAynRAmnBU8/GLK1tOBbFkR8lZShFZsMwehxIjp1 VkAA== |
| MIME-Version | 1.0 |
| X-Received | by 10.49.133.68 with SMTP id pa4mr3046121qeb.50.1361632296161; Sat, 23 Feb 2013 07:11:36 -0800 (PST) |
| In-Reply-To | <CABicbJLzQ9AHrGuaooiBRk45U5CHZYw6CodJFiQvAuF4+7kToA@mail.gmail.com> |
| References | <CABicbJLzQ9AHrGuaooiBRk45U5CHZYw6CodJFiQvAuF4+7kToA@mail.gmail.com> |
| Date | Sat, 23 Feb 2013 16:11:36 +0100 |
| Subject | Re: Correct handling of case in unicode and regexps |
| From | Vlastimil Brom <vlastimil.brom@gmail.com> |
| To | Devin Jeanpierre <jeanpierreda@gmail.com> |
| Content-Type | text/plain; charset=ISO-8859-1 |
| Content-Transfer-Encoding | quoted-printable |
| Cc | "comp.lang.python" <python-list@python.org> |
| 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.2348.1361632298.2939.python-list@python.org> (permalink) |
| Lines | 39 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1361632298 news.xs4all.nl 6912 [2001:888:2000:d::a6]:36119 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:39672 |
Show key headers only | View raw
2013/2/23 Devin Jeanpierre <jeanpierreda@gmail.com>:
> Hi folks,
>
> I'm pretty unsure of myself when it comes to unicode. As I understand
> it, you're generally supposed to compare things in a case insensitive
> manner by case folding, right? So instead of a.lower() == b.lower()
> (the ASCII way), you do a.casefold() == b.casefold()
>
> However, I'm struggling to figure out how regular expressions should
> treat case. Python's re module doesn't "work properly" to my
> understanding, because:
>
> >>> a = 'ss'
> >>> b = 'ß'
> >>> a.casefold() == b.casefold()
> True
> >>> re.match(re.escape(a), b, re.UNICODE | re.IGNORECASE)
> >>> # oh dear!
>
> In addition, it seems improbable that this ever _could_ work. Because
> if it did work like that, then what would the value be of
> re.match('s', 'ß', re.UNICODE | re.IGNORECASE).end() ? 0.5?
>
> I'd really like to hear the thoughts of people more experienced with
> unicode. What is the ideal correct behavior here? Or do I
> misunderstand things?
>
> -- Devin
> --
> http://mail.python.org/mailman/listinfo/python-list
Hi,
you may check the new regex implementation
https://pypi.python.org/pypi/regex
which does support casefolding in case insensitive matches (beyond
many other features and improvements comparing to re)
hth,
vbr
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Correct handling of case in unicode and regexps Vlastimil Brom <vlastimil.brom@gmail.com> - 2013-02-23 16:11 +0100
csiph-web