Skip to content

Instantly share code, notes, and snippets.

View NiCkEl5's full-sized avatar

Jaime Labra NiCkEl5

  • NiCkEl Solutions
  • Barcelona, Spain
View GitHub Profile
@NiCkEl5
NiCkEl5 / testmodulo5.sol
Created March 3, 2019 23:17
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.4.24+commit.e67f0147.js&optimize=false&gist=
pragma solidity ^0.4.24;
/**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/
library SafeMath {
/**
* @dev Multiplies two numbers, throws on overflow.
*/
function phoneNumberFormat(phone){
phoneAux = phone.replace(/\D/g, '')
if (phoneAux.length == 10){
parsedPhone = phoneAux.substr(0,3) +"-"+phoneAux.substr(3,3)+"-"+phoneAux.substr(6,phoneAux.length)
}
else if(phoneAux.length == 11 && phoneAux.substr(0,1) == "1"){
parsedPhone = phoneAux.substr(1,3) +"-"+phoneAux.substr(4,3)+"-"+phoneAux.substr(7,phoneAux.length)
}
else{
parsedPhone = phoneAux