Skip to content

Instantly share code, notes, and snippets.

@THUFIR
Created March 26, 2012 17:05
Show Gist options
  • Save THUFIR/2206528 to your computer and use it in GitHub Desktop.
Save THUFIR/2206528 to your computer and use it in GitHub Desktop.
cats
line1 = "Cats are smarter than dogs";
line2 = "Dogs also like meat";
if ( line1 =~ /Cats(.*)/ )
puts "Line1 starts with Cats"
end
if ( line2 =~ /Cats(.*)/ )
puts "Line2 starts with Dogs"
end
def match (s)
result = case s
when (s =~ /Cats(.*)/ ) then "cats"
else "no cats"
end
puts result
end
match(line1)
match(line2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment