Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
write a regex matches 800-555-1212, 555-1212, and also (800) 555-1212.
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  16 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
iMath  
View profile  
 More options Sep 28 2012, 8:31 pm
Newsgroups: comp.lang.python
From: iMath <redstone-c...@163.com>
Date: Fri, 28 Sep 2012 17:31:40 -0700 (PDT)
Local: Fri, Sep 28 2012 8:31 pm
Subject: write a regex matches 800-555-1212, 555-1212, and also (800) 555-1212.
write a regex matches 800-555-1212, 555-1212, and also (800) 555-1212.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tim Chase  
View profile  
 More options Sep 28 2012, 9:34 pm
Newsgroups: comp.lang.python
From: Tim Chase <python.l...@tim.thechases.com>
Date: Fri, 28 Sep 2012 20:35:41 -0500
Local: Fri, Sep 28 2012 9:35 pm
Subject: Re: write a regex matches 800-555-1212, 555-1212, and also (800) 555-1212.
On 09/28/12 19:31, iMath wrote:

> write a regex matches 800-555-1212, 555-1212, and also (800) 555-1212.

Okay, that was pretty easy.  Thanks for the challenge :-)

-tkc


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Paul Rubin  
View profile  
 More options Sep 28 2012, 9:42 pm
Newsgroups: comp.lang.python
From: Paul Rubin <no.em...@nospam.invalid>
Date: Fri, 28 Sep 2012 18:42:44 -0700
Local: Fri, Sep 28 2012 9:42 pm
Subject: Re: write a regex matches 800-555-1212, 555-1212, and also (800) 555-1212.

iMath <redstone-c...@163.com> writes:
> write a regex matches 800-555-1212, 555-1212, and also (800) 555-1212.

And then you have two problems.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mark Lawrence  
View profile  
 More options Sep 28 2012, 9:56 pm
Newsgroups: comp.lang.python
From: Mark Lawrence <breamore...@yahoo.co.uk>
Date: Sat, 29 Sep 2012 02:58:51 +0100
Local: Fri, Sep 28 2012 9:58 pm
Subject: Re: write a regex matches 800-555-1212, 555-1212, and also (800) 555-1212.
On 29/09/2012 02:35, Tim Chase wrote:

> On 09/28/12 19:31, iMath wrote:
>> write a regex matches 800-555-1212, 555-1212, and also (800) 555-1212.

> Okay, that was pretty easy.  Thanks for the challenge :-)

> -tkc

What's the run time speed like?  How much memory does it use?  Shouldn't
you be using the regex module from pypi instead of the standard library
re?  Guess who's borrowed the time machine?

--
Cheers.

Mark Lawrence.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tim Chase  
View profile  
 More options Sep 28 2012, 10:16 pm
Newsgroups: comp.lang.python
From: Tim Chase <python.l...@tim.thechases.com>
Date: Fri, 28 Sep 2012 21:17:07 -0500
Local: Fri, Sep 28 2012 10:17 pm
Subject: Re: write a regex matches 800-555-1212, 555-1212, and also (800) 555-1212.
On 09/28/12 20:58, Mark Lawrence wrote:

> On 29/09/2012 02:35, Tim Chase wrote:
>> On 09/28/12 19:31, iMath wrote:
>>> write a regex matches 800-555-1212, 555-1212, and also (800) 555-1212.

>> Okay, that was pretty easy.  Thanks for the challenge :-)

> What's the run time speed like?

O(1)

r = re.compile(
    "800-555-1212|"
    "555-1212|"
   r"\(800\) 555-1212"
    )

(okay, so I also have one that solves the OP's underqualified
problem, but without the OP at least *trying* to code up an answer
and asking for help with it, I've give the snarky solution :-)

> How much memory does it use?

Insignificant.

> Shouldn't you be using the regex module from pypi instead of the
> standard library re?

Only if the OP requested it ;-)

> Guess who's borrowed the time machine?

Neutrino!

-tkc


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ian Kelly  
View profile  
 More options Sep 28 2012, 11:26 pm
Newsgroups: comp.lang.python
From: Ian Kelly <ian.g.ke...@gmail.com>
Date: Fri, 28 Sep 2012 21:25:35 -0600
Local: Fri, Sep 28 2012 11:25 pm
Subject: Re: write a regex matches 800-555-1212, 555-1212, and also (800) 555-1212.
On Fri, Sep 28, 2012 at 8:17 PM, Tim Chase

Mine is simpler and faster.

r = re.compile("")


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Steven D'Aprano  
View profile  
 More options Sep 28 2012, 11:30 pm
Newsgroups: comp.lang.python
From: Steven D'Aprano <steve+comp.lang.pyt...@pearwood.info>
Date: 29 Sep 2012 03:30:17 GMT
Local: Fri, Sep 28 2012 11:30 pm
Subject: Re: write a regex matches 800-555-1212, 555-1212, and also (800) 555-1212.

On Fri, 28 Sep 2012 21:25:35 -0600, Ian Kelly wrote:
> Mine is simpler and faster.

> r = re.compile("")

The OP doesn't say that you have to compile it, so just:

''

wins.

--
Steven


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tim Chase  
View profile  
 More options Sep 28 2012, 11:41 pm
Newsgroups: comp.lang.python
From: Tim Chase <python.l...@tim.thechases.com>
Date: Fri, 28 Sep 2012 22:42:23 -0500
Local: Fri, Sep 28 2012 11:42 pm
Subject: Re: write a regex matches 800-555-1212, 555-1212, and also (800) 555-1212.
On 09/28/12 22:25, Ian Kelly wrote:

> On Fri, Sep 28, 2012 at 8:17 PM, Tim Chase
>>>> On 09/28/12 19:31, iMath wrote:
>>>>> write a regex matches 800-555-1212, 555-1212, and also (800) 555-1212.

>> r = re.compile(
>>     "800-555-1212|"
>>     "555-1212|"
>>    r"\(800\) 555-1212"
>>     )

> Mine is simpler and faster.

> r = re.compile("")

doh!  «smacks forehead»  Yours is FAR more efficient, and much more
readable than mine.  iMath's teacher will be pleased :-)

-tkc


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tim Chase  
View profile  
 More options Sep 28 2012, 11:49 pm
Newsgroups: comp.lang.python
From: Tim Chase <python.l...@tim.thechases.com>
Date: Fri, 28 Sep 2012 22:50:10 -0500
Local: Fri, Sep 28 2012 11:50 pm
Subject: Re: write a regex matches 800-555-1212, 555-1212, and also (800) 555-1212.
On 09/28/12 22:30, Steven D'Aprano wrote:

> On Fri, 28 Sep 2012 21:25:35 -0600, Ian Kelly wrote:

>> Mine is simpler and faster.

>> r = re.compile("")

> The OP doesn't say that you have to compile it, so just:

> ''

> wins.

OP doesn't say it even has to be a string, so I guess

wins. :-P

It's-too-late-on-a-Friday-night'ly yers,

-tkc


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Devin Jeanpierre  
View profile  
 More options Sep 29 2012, 12:26 am
Newsgroups: comp.lang.python
From: Devin Jeanpierre <jeanpierr...@gmail.com>
Date: Sat, 29 Sep 2012 00:25:50 -0400
Local: Sat, Sep 29 2012 12:25 am
Subject: Re: write a regex matches 800-555-1212, 555-1212, and also (800) 555-1212.

On Fri, Sep 28, 2012 at 9:58 PM, Mark Lawrence <breamore...@yahoo.co.uk> wrote:
> What's the run time speed like?  How much memory does it use?  Shouldn't you
> be using the regex module from pypi instead of the standard library re?
> Guess who's borrowed the time machine?

O(n), O(1), and I used RE2.

-- Devin


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Fg Nu  
View profile  
 More options Sep 29 2012, 12:27 am
Newsgroups: comp.lang.python
From: Fg Nu <fgn...@yahoo.com>
Date: Fri, 28 Sep 2012 21:25:26 -0700 (PDT)
Local: Sat, Sep 29 2012 12:25 am
Subject: Re: write a regex matches 800-555-1212, 555-1212, and also (800) 555-1212.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mark Lawrence  
View profile  
 More options Sep 29 2012, 5:36 am
Newsgroups: comp.lang.python
From: Mark Lawrence <breamore...@yahoo.co.uk>
Date: Sat, 29 Sep 2012 10:38:17 +0100
Local: Sat, Sep 29 2012 5:38 am
Subject: Re: write a regex matches 800-555-1212, 555-1212, and also (800) 555-1212.
On 29/09/2012 04:30, Steven D'Aprano wrote:

> On Fri, 28 Sep 2012 21:25:35 -0600, Ian Kelly wrote:

>> Mine is simpler and faster.

>> r = re.compile("")

> The OP doesn't say that you have to compile it, so just:

> ''

> wins.

My understanding is that Python 3.3 has regressed the performance of ''.
  Surely the Python devs can speed the performance back up and, just for
us, use less memory at the same time?

--
Cheers.

Mark Lawrence.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Chris Angelico  
View profile  
 More options Sep 29 2012, 6:05 am
Newsgroups: comp.lang.python
From: Chris Angelico <ros...@gmail.com>
Date: Sat, 29 Sep 2012 20:05:33 +1000
Local: Sat, Sep 29 2012 6:05 am
Subject: Re: write a regex matches 800-555-1212, 555-1212, and also (800) 555-1212.

On Sat, Sep 29, 2012 at 7:38 PM, Mark Lawrence <breamore...@yahoo.co.uk> wrote:

> My understanding is that Python 3.3 has regressed the performance of ''.
> Surely the Python devs can speed the performance back up and, just for us,
> use less memory at the same time?

Yes, but to do that we'd have to make Python more Australia-focused
instead of US-centric. As of Python 3.4, the empty string will be
lazily evaluated and be delimited by redback spiders instead of
quotes. That will give a 25% speed and 50% memory usage improvement,
but you'll need to be careful you don't get bitten.

ChrisA


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mark Lawrence  
View profile  
 More options Sep 29 2012, 6:47 am
Newsgroups: comp.lang.python
From: Mark Lawrence <breamore...@yahoo.co.uk>
Date: Sat, 29 Sep 2012 11:50:04 +0100
Local: Sat, Sep 29 2012 6:50 am
Subject: Re: write a regex matches 800-555-1212, 555-1212, and also (800) 555-1212.
On 29/09/2012 11:05, Chris Angelico wrote:

> On Sat, Sep 29, 2012 at 7:38 PM, Mark Lawrence <breamore...@yahoo.co.uk> wrote:

>> My understanding is that Python 3.3 has regressed the performance of ''.
>> Surely the Python devs can speed the performance back up and, just for us,
>> use less memory at the same time?

> Yes, but to do that we'd have to make Python more Australia-focused
> instead of US-centric. As of Python 3.4, the empty string will be
> lazily evaluated and be delimited by redback spiders instead of
> quotes. That will give a 25% speed and 50% memory usage improvement,
> but you'll need to be careful you don't get bitten.

> ChrisA

I'll happily admit that I don't like the way this is going.  Do you
(plural) think we should take this across to python ideas?

--
Cheers.

Mark Lawrence.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ian Kelly  
View profile  
 More options Sep 29 2012, 1:05 pm
Newsgroups: comp.lang.python
From: Ian Kelly <ian.g.ke...@gmail.com>
Date: Sat, 29 Sep 2012 11:04:55 -0600
Local: Sat, Sep 29 2012 1:04 pm
Subject: Re: write a regex matches 800-555-1212, 555-1212, and also (800) 555-1212.

On Sat, Sep 29, 2012 at 3:38 AM, Mark Lawrence <breamore...@yahoo.co.uk> wrote:
> My understanding is that Python 3.3 has regressed the performance of ''.
> Surely the Python devs can speed the performance back up and, just for us,
> use less memory at the same time?

At least it will be stored as a Latin-1 '' for efficiency and not a
bloated UCS-4 ''.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Chris Angelico  
View profile  
 More options Sep 29 2012, 7:26 pm
Newsgroups: comp.lang.python
From: Chris Angelico <ros...@gmail.com>
Date: Sun, 30 Sep 2012 09:26:20 +1000
Local: Sat, Sep 29 2012 7:26 pm
Subject: Re: write a regex matches 800-555-1212, 555-1212, and also (800) 555-1212.
On Sun, Sep 30, 2012 at 6:51 AM, Tim Delaney

<timothy.c.dela...@gmail.com> wrote:
> Personally I voted for the Fierce Snake[1][2] as the delimiter, but it was
> voted down as "not Pythonic" enough.
> I'm sure they were using that as a euphamism for "Python*ish*" though.

> [1] https://en.wikipedia.org/wiki/Inland_Taipan
> [2] It's is so pretty:
> https://upload.wikimedia.org/wikipedia/commons/f/fe/Fierce_Snake-Oxyu...

A tempting idea, but it's rather a large delimiter. We should reserve
that for multi-line strings, I think. Although you may have a problem
with i18n; when you take your code to the southern hemisphere, the
snake will be facing the other way, so what you thought was an
open-quote marker is now a close-quote marker instead. Could get
awkward for naive coders.

ChrisA


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »