Skip to content

Instantly share code, notes, and snippets.

@jarsen
Created May 22, 2010 21:09
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/410366 to your computer and use it in GitHub Desktop.
Save jarsen/410366 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby -wKU
require 'highline/import'
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>$/
input = ask "Input text: "
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
input = ask "Input text: "
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment