Thursday, March 19, 2015

Where to put the optional marker in a regex?

I'm looking back at my AIS VDM python regular expressions this morning.  It seems obvious now that I look at this code block, but when a field is missing, I'd rather get a None back, so the "?" goes outside the named regex block.


In [1]: import re

In [2]: a = re.compile(r'(?P<seq_id>[0-9]?)')

In [3]: b = re.compile(r'(?P<seq_id>[0-9])?')

In [4]: a.match('').groupdict()
Out[4]: {'seq_id': ''}

In [5]: b.match('').groupdict()

Out[5]: {'seq_id': None}

Tuesday, March 17, 2015

Dynamic Ocean Management

I'm to lazy to switch to a machine that has Photoshop and fix up the images, but check out this article on "Dynamic Ocean Management: Identifying the Critical Ingredients of Dynamic Approaches to Ocean Resource Management" that talks about WhaleALERT!  doi:10.1093/biosci/biv018