Nick Crawford Evolution and more…

30Apr/090

Thanks for a great term

Just wanted to thank my students, all ~44 of you, for putting up with my stammering explanations of genetics. I sure learned a ton and I hope you did too. Good luck with your finals.

Filed under: Courses No Comments
30Apr/090

RegEx to id comma-space(s) or space(s) delimited text

I'm not all that great at RegEx, but I needed split a line of text on commas followed by spaces and/or by spaces (including tabs). 30 minutes later after swearing and sweating with iPython, I produced the following little expression. Who needs the CSV module?

 
re.compile(',(?:\s*)|\s*')
 

Example Usage:

  1. line = 'one, two three four, five'
  2. pattern = re.compile(',(?:\s*)|\s*')
  3. line.pattern(split)
  4. >>> ['one', 'two', 'three', 'four', 'five']
Filed under: Blog No Comments