Skip to content

Instantly share code, notes, and snippets.

@ravicious
Created December 24, 2008 14:17
Show Gist options
  • Save ravicious/39690 to your computer and use it in GitHub Desktop.
Save ravicious/39690 to your computer and use it in GitHub Desktop.
irb -r roznicadat.rb
irb(main):001:0> d1 = "28-09-1993"
=> "28-09-1993"
irb(main):002:0> Scan(d1)
Poprawna data
=> nil
irb(main):003:0> d1 = "2809-1993"
=> "2809-1993"
irb(main):004:0> Scan(d1)
Niepoprawna data
=> nil
irb(main):005:0>
def Scan(text)
case text
when /^([0-9]{1,2})[-\.]([0-9]{1,2})[-\.]([0-9]{4})/
puts "Poprawna data"
else
puts "Niepoprawna data"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment