Sha256: 80df04e78e489a579bdedcad04bb44c78bc728d183ab7cd129a4b62c4662f29c

Contents?: true

Size: 480 Bytes

Versions: 131

Compression:

Stored size: 480 Bytes

Contents

function clean(phone_number)
    # Main machinery is in the regex expression.
    NXX = "[2-9][\\d]{2}"
    country = "(?:\\+?1)?"
    area = "\\(?\\s*($NXX)\\s*\\)?"
    exchange = "($NXX)"
    subscriber = "([\\d]{4})"
    fillers = "\\s*(?:\\.|-)?\\s*"
    r = Regex("^\\s*$country$fillers$area$fillers$exchange$fillers$subscriber\\s*\$")

    result = match(r, phone_number)

    if result != nothing
        result = string(result.captures...)
    end

    return result
end

Version data entries

131 entries across 131 versions & 1 rubygems

Version Path
trackler-2.2.1.139 tracks/julia/exercises/phone-number/example.jl
trackler-2.2.1.138 tracks/julia/exercises/phone-number/example.jl
trackler-2.2.1.137 tracks/julia/exercises/phone-number/example.jl
trackler-2.2.1.136 tracks/julia/exercises/phone-number/example.jl
trackler-2.2.1.135 tracks/julia/exercises/phone-number/example.jl
trackler-2.2.1.134 tracks/julia/exercises/phone-number/example.jl
trackler-2.2.1.133 tracks/julia/exercises/phone-number/example.jl
trackler-2.2.1.132 tracks/julia/exercises/phone-number/example.jl
trackler-2.2.1.131 tracks/julia/exercises/phone-number/example.jl
trackler-2.2.1.130 tracks/julia/exercises/phone-number/example.jl
trackler-2.2.1.129 tracks/julia/exercises/phone-number/example.jl
trackler-2.2.1.128 tracks/julia/exercises/phone-number/example.jl
trackler-2.2.1.127 tracks/julia/exercises/phone-number/example.jl
trackler-2.2.1.126 tracks/julia/exercises/phone-number/example.jl
trackler-2.2.1.125 tracks/julia/exercises/phone-number/example.jl
trackler-2.2.1.124 tracks/julia/exercises/phone-number/example.jl
trackler-2.2.1.123 tracks/julia/exercises/phone-number/example.jl
trackler-2.2.1.122 tracks/julia/exercises/phone-number/example.jl
trackler-2.2.1.121 tracks/julia/exercises/phone-number/example.jl
trackler-2.2.1.120 tracks/julia/exercises/phone-number/example.jl