This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #lsauer.com, 2013 | |
| #Note: -)for convenience the function uses the re-module, but can be rewritten to fit into a lambda expression | |
| # -)choose any other, more-expressive return type such as NumPy's `nan` over None if you like | |
| #demonstrative-version: | |
| def parseInt(sin): | |
| import re | |
| return int(''.join([c for c in re.split(r'[,.]',str(sin))[0] if c.isdigit()])) if re.match(r'\d+', str(sin), re.M) and not callable(sin) else None | |
| #via a simple regex: |