Advertisement
paulogp

Regular Expression - Thousands

May 14th, 2015
270
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.14 KB | None | 0 0
  1. import re
  2.  
  3. message = "12345678"
  4. print("{0}".format(re.sub(r'[0-9](?=(?:[0-9]{3})+(?![0-9]))', '\g<0>,', str(message))))
  5.  
  6. # output: 12,345,678
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement