Created
October 1, 2015 02:43
-
-
Save carlosdiaz/bbaa986329be1674d8fd to your computer and use it in GitHub Desktop.
Based on json representation http://www.json.org/number
This file contains 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
import re | |
str = '-1.95' | |
#str = '0.3456' | |
#str = '1.341516' | |
#str = '0.89788' | |
#yes, large regular expression but seems it solves, tested with different scenarios | |
pattern = re.compile(r'''^((-\d*)(.\d*)|(0.\d*)|((0.\d*(e|E)(\+|\-)\d))|((-\d*)(.\d*))(((e|E)(\+|\-)\d)))$''', re.VERBOSE) | |
print pattern.match(str) | |
if match: | |
print 'found', match.group() | |
else: | |
print 'did not find' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment