Skip to content

Instantly share code, notes, and snippets.

@eksperimental
Created March 23, 2015 17:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eksperimental/fea870f40646d71e3440 to your computer and use it in GitHub Desktop.
Save eksperimental/fea870f40646d71e3440 to your computer and use it in GitHub Desktop.
is_regex
defmacro is_regex(term) do
quote do
is_tuple(unquote(Macro.escape term)) and (
(elem(unquote(Macro.escape term), 0) in [:sigil_r, :sigil_R, :r, :R]) or
(elem( elem(unquote(Macro.escape term), 2), 0 ) == {:__struct__, Regex})
)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment