Created
June 26, 2015 06:04
-
-
Save theeluwin/ec72c525db787629ec91 to your computer and use it in GitHub Desktop.
Decimal mark regex (python example).
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
| import re | |
| def comma(value): | |
| if not value.isdigit(): | |
| raise ValueError("input must be an integer") | |
| return re.sub('\B(?=(\d{3})+(?!\d))', ',', str(int(value))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment