re.split

Sunday 26 October 2003This is nearly 21 years old. Be careful.

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.

Comments

[gravatar]
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:

Ignore this:
Leave this empty:
Name is required. Either email or web are required. Email won't be displayed and I won't spam you. Your web site won't be indexed by search engines.
Don't put anything here:
Leave this empty:
Comment text is Markdown.