How to match a variable list of items separated by commas
- by user261915
I want to turn something like this
CS 240, CS 246, ECE 222, ... (more or less); Software Engineering students only
into
('CS 240', 'CS 246', 'ECE 222', 'ECE 220')
in Python, code that matches a single course looks like
>>> re.search('([A-Z]{2,5} \d{3})', 'SE 112').groups()
('SE 112',)
I prefer a regular expression only method because I have a bunch of other alternate reg exps using '|' to combine them. However, a method with split is acceptable.