Sha256: 74eaa4977087e56f292cc3da5b2f385bd910805933d4e896b035661b336078c0
Contents?: true
Size: 533 Bytes
Versions: 180
Compression:
Stored size: 533 Bytes
Contents
data class PhoneNumber(private val rawNumber: String) { companion object { private val validationRegex = Regex("^1?(\\d{10})$") } private val cleanedNumber = rawNumber.replace(Regex("[^\\d]"), "") val number = validationRegex.matchEntire(cleanedNumber)?.groupValues?.last() ?: "0000000000" val areaCode = number.substring(0, 3) val exchangeCode = number.substring(3, 6) val subscriberNumber = number.substring(6, 10) override fun toString() = "($areaCode) $exchangeCode-$subscriberNumber" }
Version data entries
180 entries across 180 versions & 1 rubygems