Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!news.mb-net.net!open-news-network.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'matches': 0.07; 'pypi': 0.07; 'lawrence': 0.09; 'cc:addr:python-list': 0.10; ';-)': 0.11; ':-)': 0.13; 'library': 0.15; '-tkc': 0.16; 'from:addr:python.list': 0.16; 'from:addr:tim.thechases.com': 0.16; 'from:name:tim chase': 0.16; 'machine?': 0.16; 'message- id:@tim.thechases.com': 0.16; 're.compile(': 0.16; 'received:70.251': 0.16; 'received:dsl.rcsntx.swbell.net': 0.16; 'received:rcsntx.swbell.net': 0.16; 'received:swbell.net': 0.16; 'wrote:': 0.17; "shouldn't": 0.17; 'tim': 0.18; '>>>': 0.18; 'memory': 0.18; 'module': 0.19; 'cc:2**0': 0.23; "i've": 0.23; 'cc:no real name:2**0': 0.24; 'least': 0.25; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'guess': 0.27; 'run': 0.28; 'chase': 0.29; 'use?': 0.29; 'code': 0.31; 'asking': 0.32; 'skip:8 10': 0.32; "who's": 0.32; 'thanks': 0.34; 'problem,': 0.35; 'but': 0.36; 'subject: (': 0.36; 'does': 0.37; 'subject:: ': 0.38; 'mark': 0.38; 'instead': 0.39; 'skip:" 10': 0.40; 'subject:-': 0.40; 'help': 0.40; 'skip:u 10': 0.60; 'subject:, ': 0.61; 'received:50.22': 0.84; 'subject:write': 0.84; 'to:addr:yahoo.co.uk': 0.84 Date: Fri, 28 Sep 2012 21:17:07 -0500 From: Tim Chase User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.24) Gecko/20111120 Icedove/3.1.16 MIME-Version: 1.0 To: Mark Lawrence Subject: Re: write a regex matches 800-555-1212, 555-1212, and also (800) 555-1212. References: <5066506D.4020702@tim.thechases.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - boston.accountservergroup.com X-AntiAbuse: Original Domain - python.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tim.thechases.com X-Source: X-Source-Args: X-Source-Dir: Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 37 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1348884961 news.xs4all.nl 6857 [2001:888:2000:d::a6]:33047 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:30456 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