Message from discussion
write a regex matches 800-555-1212, 555-1212, and also (800) 555-1212.
Received: by 10.181.11.234 with SMTP id el10mr151181wid.2.1348889169099;
Fri, 28 Sep 2012 20:26:09 -0700 (PDT)
Path: q11ni92560240wiw.1!nntp.google.com!proxad.net!feeder1-2.proxad.net!usenet-fr.net!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path: <ian.g.ke...@gmail.com>
X-Original-To: python-l...@python.org
Delivered-To: python-l...@mail.python.org
X-Spam-Status: OK 0.032
X-Spam-Evidence: '*H*': 0.94; '*S*': 0.00; 'matches': 0.07;
'lawrence': 0.09; 'sep': 0.09; ':-)': 0.13;
'received:74.125.82.44': 0.15; 're.compile(': 0.16; 'wrote:':
0.17; 'tim': 0.18; '>>>': 0.18; 'subject:) ': 0.20; 'simpler':
0.22; 'header:In-Reply-To:1': 0.25; 'message-id:@mail.gmail.com':
0.27; 'run': 0.28; '>>>>': 0.29; 'chase': 0.29; 'fri,': 0.30;
'skip:8 10': 0.32; 'received:74.125.82': 0.33; 'to:addr:python-
list': 0.33; 'received:google.com': 0.34; 'thanks': 0.34; 'mine':
0.35; 'pm,': 0.35; 'received:74.125': 0.36; 'subject: (': 0.36;
'subject:: ': 0.38; 'mark': 0.38; 'to:addr:python.org': 0.39;
'skip:" 10': 0.40; 'subject:-': 0.40; 'header:Received:5': 0.40;
'subject:, ': 0.61; 'subject:write': 0.84; 'to:name:python': 0.84;
'faster.': 0.91
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
h=mime-version:in-reply-to:references:from:date:message-id:subject:to
:content-type; bh=iP4DTPq+myPGIn6ESyFW+EoHD+wjzdLA1YDRh4PW0n0=;
b=fbv0PAEx50oDX7r/XZ7xPPWdaZtfYMuT08cPNkbJjqs4Ph6Mx1IMy3KMNOvUH7NqUP
qwldx4XkyhuhMotfpWnHwwryz1SfwfokFlKBtclYPdy+WxfmDwG3r0KJgb9NHl9NI4LH
9cvr+bWmGfEt1XnfO5KgokowPmuIYoiyfpkZHkHj8VkWNb7yYatxVxl89LSh/rE/e03f
Tsf2L7HXexNdqPyXESKTjQCKNZpEz67QObKBD197pItpHH+H/HWgkZl2x2h9V8YfN9ZW
kz+lcivuc7xJTsuM2VBvNCuPAn5D/sGl6Geumgty+UuG4kqHF4fnoi4Pr208DF5OQbz9
mYBQ==
MIME-Version: 1.0
In-Reply-To: <50665A23.1060300@tim.thechases.com>
References: <de40c5ae-e51f-4b21-9355-da06a4882c89@googlegroups.com>
<5066506D.4020702@tim.thechases.com> <k45kg5$qp...@ger.gmane.org>
<50665A23.1060...@tim.thechases.com>
From: Ian Kelly <ian.g.ke...@gmail.com>
Date: Fri, 28 Sep 2012 21:25:35 -0600
Subject: Re: write a regex matches 800-555-1212, 555-1212,
and also (800) 555-1212.
To: Python <python-l...@python.org>
X-BeenThere: python-l...@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-requ...@python.org?subject=unsubscribe>
List-Archive: <http://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-l...@python.org>
List-Help: <mailto:python-list-requ...@python.org?subject=help>
List-Subscribe: <http://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-requ...@python.org?subject=subscribe>
Newsgroups: comp.lang.python
Message-ID: <mailman.1600.1348889168.27098.python-l...@python.org>
Lines: 22
NNTP-Posting-Host: 2001:888:2000:d::a6
X-Trace: 1348889168 news.xs4all.nl 6865 [2001:888:2000:d::a6]:44516
X-Complaints-To: ab...@xs4all.nl
Content-Type: text/plain; charset=ISO-8859-1
On Fri, Sep 28, 2012 at 8:17 PM, Tim Chase
<python.l...@tim.thechases.com> wrote:
> 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"
> )
Mine is simpler and faster.
r = re.compile("")