Last active
August 10, 2017 11:30
-
-
Save emanoelqueiroz/551bd99c7aa79af49a53b30fa018aa95 to your computer and use it in GitHub Desktop.
Utilitários para tratar de números.
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
/** | |
* Utilitários para tratar de números. | |
*/ | |
export default { | |
/** | |
* Método para deixar apenas números na string. | |
* | |
* @param {String} str String que será manipulada. | |
* @return {String} Retorna apenas os números da string. | |
*/ | |
soNumeros(str) { | |
if (!str) | |
return str; | |
return str.replace(/[^0-9][A-z]?/g, ''); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment