Powered by AppSignal & Oban Pro
Would you like to see your link here? Contact us

Phone Number Parsing

exercises/phone_number_parsing.livemd

Phone Number Parsing

Mix.install([
  {:youtube, github: "brooklinjazz/youtube"},
  {:hidden_cell, github: "brooklinjazz/hidden_cell"},
  {:tested_cell, github: "brooklinjazz/tested_cell"},
  {:utils, path: "#{__DIR__}/../utils"}
])

Navigation

Return Home Report An Issue

Phone Number Parsing

You have been provided a large string of phone numbers. The problem is, each phone number does not follow a standard format.

You have been asked to convert them from the non standardized format into a standard format.

Phone numbers will be given in the following formats:

  • 1231231234
  • 123 123 1234
  • (123)-123-1234
  • (123) 123 1234
  • (123)123-1234

You need to convert them into the format 123-123-1234.

text = "
1231231234
123 123 1234
(123)-123-1234
(123) 123 1234
(123)123-1234
"
PhoneNumber.parse(text)
"
123-123-1234
123-123-1234
123-123-1234
123-123-1234
123-123-1234
"

Enter your answer below.

defmodule PhoneNumber do
  def parse(string) do
  end
end

Utils.feedback(:phone_number_parsing, PhoneNumber)

Commit Your Progress

Run the following in your command line from the beta_curriculum folder to track and save your progress in a Git commit.

$ git add .
$ git commit -m "finish phone number parsing exercise"

Up Next

Previous Next
Email Validation Classified