Skip to content

Instantly share code, notes, and snippets.

@mattsnyder
Created August 28, 2016 15:30
Show Gist options
  • Save mattsnyder/007222fac550d72a233195e92db11307 to your computer and use it in GitHub Desktop.
Save mattsnyder/007222fac550d72a233195e92db11307 to your computer and use it in GitHub Desktop.
@char_types [{~r/(?<number>\d)/, :digit}, {~r/(?<letter>\w)/, :letter}, {~r/(?<allowed>[\(\)\.\-])/, :allowed} ]
defp identify_char(char) do
{_, type} = Enum.find(@char_types, {nil, :unknown}, fn {reg, type} ->
String.match?(char, reg)
end)
{type, char}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment