re.findall(r'\b[0-9]{2,7}-[0-9]{2}-[0-9]{2}\b', txt)
\b - a word boundary.
[0-9]{2,7} - 2 to 7 digits
- - a hyphen-minus
[0-9]{2} - exactly 2 digits
- - a hyphen-minus
[0-9]{2} - exactly 2 digits
\b - a word boundary.
Seems quite straightforward to me.
be interpreted at some point as 12
dozen, which may even be appropriate but a bit of a surprise perhaps.
-Original Message-
From: Python-list On
Behalf Of Peter J. Holzer via Python-list
Sent: Friday, November 17, 2023 6:18 AM
To: python-list@python.org
Subject: Re: Code improvement
MRAB ha scritto:
Bare excepts are a very bad idea.
I know, you're right but to test the CAS numbers were inside a string
(txt) and instead of the 'open(file)' there was 'io.StingIO(txt)' so the
risk was almost null. When I copied it here I didn't think about it.
Sorry.
--
https://mail.python.
On 2023-11-17 09:38, jak via Python-list wrote:
Mike Dewhirst ha scritto:
On 15/11/2023 10:25 am, MRAB via Python-list wrote:
On 2023-11-14 23:14, Mike Dewhirst via Python-list wrote:
I'd like to improve the code below, which works. It feels clunky to me.
I need to clean up user-uploaded file
Mike Dewhirst ha scritto:
On 15/11/2023 10:25 am, MRAB via Python-list wrote:
On 2023-11-14 23:14, Mike Dewhirst via Python-list wrote:
I'd like to improve the code below, which works. It feels clunky to me.
I need to clean up user-uploaded files the size of which I don't know in
advance.
Aft
On 11/17/2023 9:46 AM, Peter J. Holzer via Python-list wrote:
On 2023-11-17 07:48:41 -0500, Thomas Passin via Python-list wrote:
On 11/17/2023 6:17 AM, Peter J. Holzer via Python-list wrote:
Oh, and Python (just like Perl) allows you to embed whitespace and
comments into Regexps, which helps re
On 2023-11-17 07:48:41 -0500, Thomas Passin via Python-list wrote:
> On 11/17/2023 6:17 AM, Peter J. Holzer via Python-list wrote:
> > Oh, and Python (just like Perl) allows you to embed whitespace and
> > comments into Regexps, which helps readability a lot if you have to
> > write long regexps.
>
On 11/17/2023 6:17 AM, Peter J. Holzer via Python-list wrote:
On 2023-11-16 11:34:16 +1300, Rimu Atkinson via Python-list wrote:
Why don't you use re.findall?
re.findall(r'\b[0-9]{2,7}-[0-9]{2}-[0-9]{2}\b', txt)
I think I can see what you did there but it won't make sense to me - or
whoever l
On 2023-11-16 11:34:16 +1300, Rimu Atkinson via Python-list wrote:
> > > Why don't you use re.findall?
> > >
> > > re.findall(r'\b[0-9]{2,7}-[0-9]{2}-[0-9]{2}\b', txt)
> >
> > I think I can see what you did there but it won't make sense to me - or
> > whoever looks at the code - in future.
> >
>
On 16/11/2023 9:34 am, Rimu Atkinson via Python-list wrote:
Why don't you use re.findall?
re.findall(r'\b[0-9]{2,7}-[0-9]{2}-[0-9]{2}\b', txt)
I think I can see what you did there but it won't make sense to me -
or whoever looks at the code - in future.
That answers your specific questi
Why don't you use re.findall?
re.findall(r'\b[0-9]{2,7}-[0-9]{2}-[0-9]{2}\b', txt)
I think I can see what you did there but it won't make sense to me - or
whoever looks at the code - in future.
That answers your specific question. However, I am in awe of people who
can just "do" regula
On 2023-11-17 01:15, Mike Dewhirst via Python-list wrote:
On 15/11/2023 3:08 pm, MRAB via Python-list wrote:
On 2023-11-15 03:41, Mike Dewhirst via Python-list wrote:
On 15/11/2023 10:25 am, MRAB via Python-list wrote:
On 2023-11-14 23:14, Mike Dewhirst via Python-list wrote:
I'd like to impro
On 15/11/2023 3:08 pm, MRAB via Python-list wrote:
On 2023-11-15 03:41, Mike Dewhirst via Python-list wrote:
On 15/11/2023 10:25 am, MRAB via Python-list wrote:
On 2023-11-14 23:14, Mike Dewhirst via Python-list wrote:
I'd like to improve the code below, which works. It feels clunky to
me.
I
On 2023-11-15 03:41, Mike Dewhirst via Python-list wrote:
On 15/11/2023 10:25 am, MRAB via Python-list wrote:
On 2023-11-14 23:14, Mike Dewhirst via Python-list wrote:
I'd like to improve the code below, which works. It feels clunky to me.
I need to clean up user-uploaded files the size of whi
On 15/11/2023 10:25 am, MRAB via Python-list wrote:
On 2023-11-14 23:14, Mike Dewhirst via Python-list wrote:
I'd like to improve the code below, which works. It feels clunky to me.
I need to clean up user-uploaded files the size of which I don't know in
advance.
After cleaning they might be a
On 2023-11-14 23:14, Mike Dewhirst via Python-list wrote:
I'd like to improve the code below, which works. It feels clunky to me.
I need to clean up user-uploaded files the size of which I don't know in
advance.
After cleaning they might be as big as 1Mb but that would be super rare.
Perhaps on
16 matches
Mail list logo