Skip to content

Instantly share code, notes, and snippets.

@jarsen
Created May 26, 2010 00:12
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 jarsen/413860 to your computer and use it in GitHub Desktop.
Save jarsen/413860 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby -wKU
letters_only = /^[a-z]+$/i
phone_number = /^\(\d{3}\)\s?\d{3}-\d{4}$/
numbers_below_18 = /^(([0-1]?[0-8])|(-\d*))$/
html_tag = /^<([A-Z]*)>(.*)<\/\1>$/
print "Input text: "
input = gets.strip
until input == "quit" do
puts case input
when letters_only then "Letters"
when phone_number then "Phone Number"
when numbers_below_18 then "Number below 18"
when html_tag then "HTML tag"
else "No matches"
end
print "Input text: "
input = gets.strip
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment