Best way to convert this Ruby code to Elixir?

Simulate Regex match guards in functions - Elixir Questions - Elixir Forum