Simon discovers Python's re.split(). About one particular aspect of it (parenthesized groups are returned in the list), he says, "I'm probably the last person to find out about this", but in fact, I never even knew re.split() existed at all! I think I've wanted this functionality a half-dozen times in the past, and never thought to look in the re module to find it. Python's standard library is incredibly rich, and often solutions are hiding in places waiting for you to discover them.

tagged: » 1 reaction

Comments

[gravatar]
Keller Scholl 6:04 PM on 4 Feb 2012

Even more obscure: The .split method for strings functions similarly to the regex module, but tends to be faster for non compiled regexes.

Add a comment:

name
email
Ignore this:
not displayed and no spam.
Leave this empty:
www
not searched.
 
Name and either email or www are required.
Don't put anything here:
Leave this empty:
URLs auto-link and some tags are allowed: <a><b><i><p><br><pre>.