Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #30463

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

Date 2012-09-28 22:42 -0500
From Tim Chase <python.list@tim.thechases.com>
Subject Re: write a regex matches 800-555-1212, 555-1212, and also (800) 555-1212.
References <de40c5ae-e51f-4b21-9355-da06a4882c89@googlegroups.com> <5066506D.4020702@tim.thechases.com> <k45kg5$qpo$1@ger.gmane.org> <50665A23.1060300@tim.thechases.com> <CALwzidnA-w_S4EQuS3K46-Te-QBrdz1_yqNqVqchivpmdSB8cg@mail.gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.1602.1348890078.27098.python-list@python.org> (permalink)

Show all headers | View raw


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

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

write a regex matches 800-555-1212, 555-1212, and also (800) 555-1212. iMath <redstone-cold@163.com> - 2012-09-28 17:31 -0700
  Re: write a regex matches 800-555-1212, 555-1212, and also (800) 555-1212. Tim Chase <python.list@tim.thechases.com> - 2012-09-28 20:35 -0500
  Re: write a regex matches 800-555-1212, 555-1212, and also (800) 555-1212. Paul Rubin <no.email@nospam.invalid> - 2012-09-28 18:42 -0700
  Re: write a regex matches 800-555-1212, 555-1212, and also (800) 555-1212. Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-09-29 02:58 +0100
  Re: write a regex matches 800-555-1212, 555-1212, and also (800) 555-1212. Tim Chase <python.list@tim.thechases.com> - 2012-09-28 21:17 -0500
  Re: write a regex matches 800-555-1212, 555-1212, and also (800) 555-1212. Ian Kelly <ian.g.kelly@gmail.com> - 2012-09-28 21:25 -0600
    Re: write a regex matches 800-555-1212, 555-1212, and also (800) 555-1212. Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-09-29 03:30 +0000
      Re: write a regex matches 800-555-1212, 555-1212, and also (800) 555-1212. Tim Chase <python.list@tim.thechases.com> - 2012-09-28 22:50 -0500
      Re: write a regex matches 800-555-1212, 555-1212, and also (800) 555-1212. Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-09-29 10:38 +0100
      Re: write a regex matches 800-555-1212, 555-1212, and also (800) 555-1212. Chris Angelico <rosuav@gmail.com> - 2012-09-29 20:05 +1000
      Re: write a regex matches 800-555-1212, 555-1212, and also (800) 555-1212. Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-09-29 11:50 +0100
      Re: write a regex matches 800-555-1212, 555-1212, and also (800) 555-1212. Ian Kelly <ian.g.kelly@gmail.com> - 2012-09-29 11:04 -0600
      Re: write a regex matches 800-555-1212, 555-1212, and also (800) 555-1212. Chris Angelico <rosuav@gmail.com> - 2012-09-30 09:26 +1000
  Re: write a regex matches 800-555-1212, 555-1212, and also (800) 555-1212. Tim Chase <python.list@tim.thechases.com> - 2012-09-28 22:42 -0500
  Re: write a regex matches 800-555-1212, 555-1212, and also (800) 555-1212. Devin Jeanpierre <jeanpierreda@gmail.com> - 2012-09-29 00:25 -0400
  Re: write a regex matches 800-555-1212, 555-1212, and also (800) 555-1212. Fg Nu <fgnu32@yahoo.com> - 2012-09-28 21:25 -0700

csiph-web