Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Math is like love -- a simple idea but it can get complicated. -- R. Drabek


devel / comp.lang.python / RE: Regular Expression bug?

SubjectAuthor
o RE: Regular Expression bug?<avi.e.gross

1
RE: Regular Expression bug?

<mailman.2141.1677807317.20444.python-list@python.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=22160&group=comp.lang.python#22160

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!news.szaf.org!fu-berlin.de!uni-berlin.de!not-for-mail
From:
Newsgroups: comp.lang.python
Subject: RE: Regular Expression bug?
Date: Thu, 2 Mar 2023 20:35:12 -0500
Lines: 73
Message-ID: <mailman.2141.1677807317.20444.python-list@python.org>
References: <CAO+295u7pkb+qpuqR4-FnX_+6A6_DEcUbKDrSJT88Exgx2Xf3w@mail.gmail.com>
<CAPTjJmqEU6r+s6Rt9x6xE6Kx_gm=YEf3MFwKMpZpkQihXUa+Jw@mail.gmail.com>
<0556af4d-279d-8bf0-973d-54ea5e30f764@wichmann.us>
<CAO+295uSGRp7LqQT=v2GiQ06ahzkEmZgqwmJX7UsJiW7H+6i2g@mail.gmail.com>
<006401d94d70$662e0c30$328a2490$@gmail.com>
Mime-Version: 1.0
Content-Type: text/plain;
charset="utf-8"
Content-Transfer-Encoding: quoted-printable
X-Trace: news.uni-berlin.de ZYLjOQjHctiMV6vgQWt58QtMxYkPzh+LVSD1xEfTmKaw==
Return-Path: <avi.e.gross@gmail.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=gmail.com header.i=@gmail.com header.b=iy6+42pg;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.000
X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; '2023': 0.07; 'mar': 0.07;
'used.': 0.07; 'wrong.': 0.07; 'angelico': 0.09; 'cc:addr:python-
list': 0.09; 'expression': 0.09; 'fact,': 0.09; 'fails': 0.09;
'other.': 0.09; 'received:108': 0.09; 'subject:bug': 0.09; 'cc:no
real name:2**0': 0.14; 'import': 0.15; 'url:mailman': 0.15;
'>>>>>': 0.16; 'mats': 0.16; 'part.': 0.16; 'python3': 0.16;
'regexp': 0.16; 'url:howto': 0.16; 'url:regex': 0.16; 'well-
known': 0.16; 'wichmann': 0.16; 'wrote:': 0.16; 'message-
id:@gmail.com': 0.18; 'thu,': 0.19; 'cc:addr:python.org': 0.20;
'fri,': 0.22; 'skip:- 10': 0.25; 'url-ip:188.166.95.178/32': 0.25;
'url-ip:188.166.95/24': 0.25; 'url:listinfo': 0.25; 'cc:2**0':
0.25; 'url-ip:188.166/16': 0.25; 'space': 0.26; 'pattern': 0.26;
'bit': 0.27; '>>>': 0.28; 'chris': 0.28; 'goes': 0.28; 'it,':
0.29; 'received:209.85.160': 0.31; 'url-ip:188/8': 0.31; 'python-
list': 0.32; 'march': 0.33; 'appreciated.': 0.34; 'header:In-
Reply-To:1': 0.34; 'received:google.com': 0.34; 'trying': 0.35;
'following': 0.35; 'from:addr:gmail.com': 0.35; 'received:209.85':
0.37; 'received:209': 0.39; 'use': 0.39; 'match': 0.40; 'want':
0.40; 'should': 0.40; 'from:': 0.62; 'to:': 0.62; 'between': 0.63;
'everything': 0.63; 'skip:r 20': 0.64; 're:': 0.64; 'upgrade':
0.64; 'your': 0.64; 'cc:': 0.69; '....': 0.76; 'sent:': 0.78;
'subject:Regular': 0.84
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20210112; t=1677807314;
h=content-language:thread-index:content-transfer-encoding
:mime-version:message-id:date:subject:in-reply-to:references:cc:to
:from:from:to:cc:subject:date:message-id:reply-to;
bh=y5vplzD2fk9+kM99LnG4kFOqiSQsH1/duoh5B1TDdQA=;
b=iy6+42pgZeo+I4REDNJ/sm+Ye6zJNwheAtQhAQT+XBRhsEvR2tY7cJ+dtj2zoyeRJQ
+SUJ7/yYX3Cfpao50Ii8J+68y8CViGOW5vLQNlJW1r7WXVmINrPjc3UTkt4Ojs2Al9fK
6tDq2uTGHUercKkngYpyea9XUEdZ1IbwL6CcR+hRgeLhiqDV7oubutB+OreNnAtX/6Qq
LPrgYKQq3lSJnuUaE7pdWh6RKLvDH2nirZPvfowP/h9SH9E8OGo8Dncaz4DUVbvziUaA
z0IhuCcftAlSexVV2sY0Xp5dCeBf+AgynHSry2rhnm0cKKxrL+9Tn+LW3hI2TWFe52nh
dZRQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20210112; t=1677807314;
h=content-language:thread-index:content-transfer-encoding
:mime-version:message-id:date:subject:in-reply-to:references:cc:to
:from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
bh=y5vplzD2fk9+kM99LnG4kFOqiSQsH1/duoh5B1TDdQA=;
b=fyXrh7BXEnxw96u+BvlhBcZO5cPn0qftZgVsoqf26O+CySggVnCdOV2PKQaIUnoDWN
WLnAtBav4fVwF0kQdSVGQVc84bBCezScrUcKDIVKnSZChIASG3yIMz1rNUXxkZZC1Deu
eNWKUeTWnYG9QnktKk9vjag4ZaI0JGBEiVVS3YLsgFD1dc/V7NwDPjueGgN6DhSV3aiq
TzGGfnNnca96Lp1A6NDfpGWJVGwnVd26XM3Ep/Ef2LMzDFh2HjE+ZeDEqdsZCAOj+QaS
mfVVw521XBO6GY79OkZRBGhuIJ9vkJQmBr/ON4lNUPFQDNFF4J93m6uE+W9SxJC4HHki
jS+Q==
X-Gm-Message-State: AO0yUKVtQU0ZBFYhwOKeOOCUI+OB2hGU9AI37QpN3rWWW9YJcCsVeo/X
hW8uBoEmOrxqnh/mnsFhEdB47J1HTeI=
X-Google-Smtp-Source: AK7set+oFLKqQihcvp+9bomQYLpKmVn2QpiEsBKQzC/c7InAsQXc+F/K0bLK3XmcbM6TsQ/goPl93Q==
X-Received: by 2002:a05:622a:40f:b0:3b3:7d5:a752 with SMTP id
n15-20020a05622a040f00b003b307d5a752mr410765qtx.50.1677807314094;
Thu, 02 Mar 2023 17:35:14 -0800 (PST)
In-Reply-To: <CAO+295uSGRp7LqQT=v2GiQ06ahzkEmZgqwmJX7UsJiW7H+6i2g@mail.gmail.com>
X-Mailer: Microsoft Outlook 16.0
Thread-Index: AQLA5ZSJpEJQTSAkfHwe5r/W+j1nyQHXCmMsAjlLj5MBTg6G4KzuIgwA
Content-Language: en-us
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
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: <https://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>
X-Mailman-Original-Message-ID: <006401d94d70$662e0c30$328a2490$@gmail.com>
X-Mailman-Original-References: <CAO+295u7pkb+qpuqR4-FnX_+6A6_DEcUbKDrSJT88Exgx2Xf3w@mail.gmail.com>
<CAPTjJmqEU6r+s6Rt9x6xE6Kx_gm=YEf3MFwKMpZpkQihXUa+Jw@mail.gmail.com>
<0556af4d-279d-8bf0-973d-54ea5e30f764@wichmann.us>
<CAO+295uSGRp7LqQT=v2GiQ06ahzkEmZgqwmJX7UsJiW7H+6i2g@mail.gmail.com>
 by: - Fri, 3 Mar 2023 01:35 UTC

It is a well-known fact, Jose, that GIGO.

The letters "n" and "m" are not interchangeable. Your pattern fails because you have "pn" in one place and "pm" in the other.

>>> s = "pn=jose pn=2017"
....
>>> s0 = r0.match(s)
>>> s0
<re.Match object; span=(0, 15), match='pn=jose pn=2017'>

-----Original Message-----
From: Python-list <python-list-bounces+avi.e.gross=gmail.com@python.org> On Behalf Of jose isaias cabrera
Sent: Thursday, March 2, 2023 8:07 PM
To: Mats Wichmann <mats@wichmann.us>
Cc: python-list@python.org
Subject: Re: Regular Expression bug?

On Thu, Mar 2, 2023 at 2:38 PM Mats Wichmann <mats@wichmann.us> wrote:
>
> On 3/2/23 12:28, Chris Angelico wrote:
> > On Fri, 3 Mar 2023 at 06:24, jose isaias cabrera <jicman@gmail.com>
wrote:
> >>
> >> Greetings.
> >>
> >> For the RegExp Gurus, consider the following python3 code:
> >> <code>
> >> import re
> >> s = "pn=align upgrade sd=2023-02-"
> >> ro = re.compile(r"pn=(.+) ")
> >> r0=ro.match(s)
> >>>>> print(r0.group(1))
> >> align upgrade
> >> </code>
> >>
> >> This is wrong. It should be 'align' because the group only goes up-to
> >> the space. Thoughts? Thanks.
> >>
> >
> > Not a bug. Find the longest possible match that fits this; as long as
> > you can find a space immediately after it, everything in between goes
> > into the .+ part.
> >
> > If you want to exclude spaces, either use [^ ]+ or .+?.
>
> https://docs.python.org/3/howto/regex.html#greedy-versus-non-greedy

This re is a bit different than the one I am used. So, I am trying to match
everything after 'pn=':

import re
s = "pm=jose pn=2017"
m0 = r"pn=(.+)"
r0 = re.compile(m0)
s0 = r0.match(s)
>>> print(s0)
None

Any help is appreciated.
--
https://mail.python.org/mailman/listinfo/python-list

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor