I
iMath
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.
iMath said: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?
Insignificant.
Shouldn't you be using the regex module from pypi instead of the
standard library re?
Guess who's borrowed the time machine?
O(1)
r = re.compile(
"800-555-1212|"
"555-1212|"
r"\(800\) 555-1212"
)
Mine is simpler and faster.
r = re.compile("")
Mine is simpler and faster.
r = re.compile("")
The OP doesn't say that you have to compile it, so just:
''
wins.
Mine is simpler and faster.
r = re.compile("")
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?
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?
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
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?
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-Oxyuranus_microlepidotus.jpg
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.