       captures = if groups do
         Enum.sort(groups)
       else
-        raise "Regex was not compiled with g"
+        raise ArgumentError, message: "regex was not compiled with g"
       end
       options  = Keyword.put(options, :capture, captures)
     end


    captures =
      case Keyword.get(options, :capture, :all) do
        :groups -> groups || raise "regex was not compiled with g"
        others  -> others
      end



  @doc """
  Returns the given captures as a list of tuples.
  Requires the regex to be compiled with the groups option.

  ## Examples

