Skip to content

Instantly share code, notes, and snippets.

@theeluwin
Created June 26, 2015 06:04
Show Gist options
  • Select an option

  • Save theeluwin/ec72c525db787629ec91 to your computer and use it in GitHub Desktop.

Select an option

Save theeluwin/ec72c525db787629ec91 to your computer and use it in GitHub Desktop.
Decimal mark regex (python example).
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