1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | @register.filter
def regex_comma_number(value,arg):
import re
__test__ = {}
re_digits_nondigits = re.compile(r'\d+|\D+')
parts = re_digits_nondigits.findall(arg % (value,))
for i in xrange(len(parts)):
s = parts[i]
if s.isdigit():
r = []
for j, c in enumerate(reversed(s)):
if j and (not (j % 3)):
r.insert(0, ',')
r.insert(0, c)
parts[i] = ''.join(r)
break
return ''.join(parts)
|
More like this
- PHP's number_format like template filter by janr 5 years, 1 month ago
- UKPhoneNumberField GB v2 by g1smd 8 months, 3 weeks ago
- Integer Currency Input by jgeewax 4 years, 8 months ago
- UKPhoneNumberField by Nathan Reynolds 4 years, 6 months ago
- UKPhoneNumberField GB v3 (improved) by g1smd 8 months, 3 weeks ago
Comments