Skip to content

Instantly share code, notes, and snippets.

@dact221
Created June 4, 2020 16:03
Show Gist options
  • Save dact221/21910246f51ad6aec0cb47ce8540ec7c to your computer and use it in GitHub Desktop.
Save dact221/21910246f51ad6aec0cb47ce8540ec7c to your computer and use it in GitHub Desktop.
isfrom2to9(n) = n != '0' && n != '1'
function clean(phone_number)
filtered = filter(isnumeric, phone_number)
n = length(filtered)
if n == 11
filtered[1] != '1' && return nothing
filtered = filtered[2:end]
n = 10
end
if n == 10
if !isfrom2to9(filtered[1]) || !isfrom2to9(filtered[4])
return nothing
else
return filtered
end
end
nothing
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment