re: Daily Challenge #32 - Hide Phone Numbers VIEW POST

FULL DISCUSSION
 

Elixir:

defmodule Phone do
  def hide(string = <<plain::binary-size(5), hidden::binary>>) do
    String.match?(string, ~r/\d{3}-\d{3}-\d{4}/) &&
      plain <> String.replace(hidden, ~r/\d/, "X")
  end
end

Uses some bitstring pattern matching :)

code of conduct - report abuse