devroom.io/drafts/2012-05-22-ruby-regex-scanning-in-a-case-statement.md
Ariejan de Vroom dbae98c4c0 Moar updates
2013-03-24 14:27:51 +01:00

533 B

title kind slug created_at tags
Ruby: regex scanning in a case statement article ruby-regex-scanning-in-a-case-statement 2012-05-22
Ruby
snippet

Here's a handy ruby snippet that might come in handy one day.

When the regex matches (input should end with " today"), you can directly grab the matched value using the special $1 variable.

:::ruby
case input
when /(.*)\stoday$/i then
  puts "Today: #{$1}"
end

I think you can see how you can bend this to your own needs.