write a regex matches 800-555-1212, 555-1212, and also (800) 555-1212.
Tim Chase
python.list at tim.thechases.com
Fri Sep 28 22:17:07 EDT 2012
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
More information about the Python-list
mailing list