title: Suggestion on replacing an is_regex call in Elixir
body: <p>Can someone help me with replacing this guard case in Elixir ?</p>
  
  <pre><code>def contains(collection,element) do
  r = case collection do
        c when is_tuple(c)           -&gt; element in tuple_to_list(c)
        c when is_list(c)            -&gt; element in c
        c when is_regex(element)     -&gt; Regex.match?(element, c)
        c when is_bitstring(element) -&gt; String.contains?(c, element)
      end
  
  if (not r), do: Message.fail(collection, element, __ENV__.function)
  end
  </code></pre>
  
  <p>Thanks</p>