Whittle it on down

DFS nospam at dfs.com
Thu May 5 08:44:48 EDT 2016


On 5/5/2016 1:39 AM, Stephen Hansen wrote:



> pattern = re.compile(r"^[A-Z\s&]+$")

> output = [x for x in list if pattern.match(x)]



Holy Shr"^[A-Z\s&]+$"  One line of parsing!

I was figuring a few list comprehensions would do it - this is better.

(note: the reason I specified 'spaces around ampersand' is so it would
remove 'Q&A' if that ever came up - but some people write 'Q & A', so
I'll live with that exception, or try to tweak it myself.

You're the man, man.

Thank you!







More information about the Python-list mailing list