On Thu, Mar 2, 2023 at 9:56 PM Alan Bawden wrote:
>
> jose isaias cabrera writes:
>
>On Thu, Mar 2, 2023 at 2:38 PM Mats Wichmann wrote:
>
>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
ject manager. pn=project name. I needed search()
rather than match().
>
> >>> s = "pn=jose pn=2017"
> ...
> >>> s0 = r0.match(s)
> >>> s0
>
>
>
>
> -Original Message-
> From: Python-list On
> Behalf Of jose isaias cab
On Thu, Mar 2, 2023 at 8:30 PM Cameron Simpson wrote:
>
> On 02Mar2023 20:06, jose isaias cabrera wrote:
> >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 =
jose isaias cabrera writes:
On Thu, Mar 2, 2023 at 2:38 PM Mats Wichmann wrote:
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)
On 02Mar2023 20:06, jose isaias cabrera wrote:
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)
`match()` matches at the start of the string. You want
;> s0
-Original Message-
From: Python-list On
Behalf Of jose isaias cabrera
Sent: Thursday, March 2, 2023 8:07 PM
To: Mats Wichmann
Cc: python-list@python.org
Subject: Re: Regular Expression bug?
On Thu, Mar 2, 2023 at 2:38 PM Mats Wichmann wrote:
>
> On 3/2/23 12:28
On Thu, Mar 2, 2023 at 2:38 PM Mats Wichmann wrote:
>
> On 3/2/23 12:28, Chris Angelico wrote:
> > On Fri, 3 Mar 2023 at 06:24, jose isaias cabrera
wrote:
> >>
> >> Greetings.
> >>
> >> For the RegExp Gurus, consider the following python3 code:
> >>
> >> import re
> >> s = "pn=align upgrade
José,
Matching can be greedy. Did it match to the last space?
What you want is a pattern that matches anything except a space (or whitespace)
followed b matching a space or something similar.
Or use a construct that makes matching non-greedy.
Avi
-Original Message-
From: Python-list
On Thu, Mar 2, 2023 at 2:32 PM <2qdxy4rzwzuui...@potatochowder.com> wrote:
>
> On 2023-03-02 at 14:22:41 -0500,
> jose isaias cabrera wrote:
>
> > For the RegExp Gurus, consider the following python3 code:
> >
> > import re
> > s = "pn=align upgrade sd=2023-02-"
> > ro = re.compile(r"pn=(.+) ")
On 3/2/23 12:28, Chris Angelico wrote:
On Fri, 3 Mar 2023 at 06:24, jose isaias cabrera wrote:
Greetings.
For the RegExp Gurus, consider the following python3 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
On 2023-03-02 at 14:22:41 -0500,
jose isaias cabrera wrote:
> For the RegExp Gurus, consider the following python3 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
>
>
> This is wrong. It should
On Fri, 3 Mar 2023 at 06:24, jose isaias cabrera wrote:
>
> Greetings.
>
> For the RegExp Gurus, consider the following python3 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
>
>
> This is wrong.
On Thu, 19 Feb 2009 13:03:59 -0800, Ron Garret wrote:
In article gnkdal$bcq$0...@news.t-online.com,
Peter Otten __pete...@web.de wrote:
Ron Garret wrote:
I'm trying to split a CamelCase string into its constituent
components.
How about
More elegant way
[x for x in re.split('([A-Z]+[a-z]+)', a) if x ]
['foo', 'Bar', 'Baz']
R.
On Feb 20, 2:03 pm, Lie Ryan lie.1...@gmail.com wrote:
On Thu, 19 Feb 2009 13:03:59 -0800, Ron Garret wrote:
In article gnkdal$bcq$0...@news.t-online.com,
Peter Otten __pete...@web.de wrote:
On Thu, 2009-02-19 at 10:55 -0800, Ron Garret wrote:
I'm trying to split a CamelCase string into its constituent components.
This kind of works:
re.split('[a-z][A-Z]', 'fooBarBaz')
['fo', 'a', 'az']
but it consumes the boundary characters. To fix this I tried using
lookahead and
On Thu, Feb 19, 2009 at 12:55 PM, Ron Garret rnospa...@flownet.com wrote:
I'm trying to split a CamelCase string into its constituent components.
This kind of works:
re.split('[a-z][A-Z]', 'fooBarBaz')
['fo', 'a', 'az']
but it consumes the boundary characters. To fix this I tried using
i wonder what fraction of people posting with bug? in their titles here
actually find bugs?
anyway, how about:
re.findall('[A-Z]?[a-z]*', 'fooBarBaz')
or
re.findall('([A-Z][a-z]*|[a-z]+)', 'fooBarBaz')
(you have to specify what you're matching and lookahead/back doesn't do
that).
andrew
Ron Garret wrote:
I'm trying to split a CamelCase string into its constituent components.
How about
re.compile([A-Za-z][a-z]*).findall(fooBarBaz)
['foo', 'Bar', 'Baz']
This kind of works:
re.split('[a-z][A-Z]', 'fooBarBaz')
['fo', 'a', 'az']
but it consumes the boundary characters.
Ron Garret wrote:
I'm trying to split a CamelCase string into its constituent components.
This kind of works:
re.split('[a-z][A-Z]', 'fooBarBaz')
['fo', 'a', 'az']
but it consumes the boundary characters. To fix this I tried using
lookahead and lookbehind patterns instead, but it doesn't
In article mailman.281.1235073821.11746.python-l...@python.org,
MRAB goo...@mrabarnett.plus.com wrote:
Ron Garret wrote:
I'm trying to split a CamelCase string into its constituent components.
This kind of works:
re.split('[a-z][A-Z]', 'fooBarBaz')
['fo', 'a', 'az']
but it
In article gnkdal$bcq$0...@news.t-online.com,
Peter Otten __pete...@web.de wrote:
Ron Garret wrote:
I'm trying to split a CamelCase string into its constituent components.
How about
re.compile([A-Za-z][a-z]*).findall(fooBarBaz)
['foo', 'Bar', 'Baz']
That's very clever. Thanks!
In article mailman.277.1235073073.11746.python-l...@python.org,
andrew cooke and...@acooke.org wrote:
i wonder what fraction of people posting with bug? in their titles here
actually find bugs?
IMHO it ought to be an invariant that len(r.split(s)) should always be
one more than
In article mailman.273.1235071607.11746.python-l...@python.org,
Albert Hopkins mar...@letterboxes.org wrote:
On Thu, 2009-02-19 at 10:55 -0800, Ron Garret wrote:
I'm trying to split a CamelCase string into its constituent components.
This kind of works:
re.split('[a-z][A-Z]',
andrew cooke wrote:
i wonder what fraction of people posting with bug? in their titles here
actually find bugs?
About 99.99%.
Unfortunately, 99.98% have found bugs in their code, not in Python.
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
24 matches
Mail list logo