Create a gist now

Instantly share code, notes, and snippets.

@dirceu /cpf.js Secret
Last active Dec 15, 2015

What would you like to do?
> cpf
'057.253.749-20'
> cpf.replace(/[^\d]/g, '')
'05725374920'
>>> cpf
'05725374920'
>>> "{}.{}.{}-{}".format(cpf[0:3], cpf[3:6], cpf[6:9], cpf[9:11])
'057.253.749-20'
>> cpf
=> "05725374920"
>> "#{cpf[0,3]}.#{cpf[3,3]}.#{cpf[6,3]}-#{cpf[9,2]}"
=> "057.253.749-20"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment