Ruby 1.9.2 invalid character property name {Katakana}: /\p{Katakana}/ workaround

OK this has nothing to do with Vim, but sometimes I want to talk about just Ruby too. I came across the following issue:

  #This is OK
  "abcアイウ".scan(/\p{Katakana}/)
  #=> ["ア", "イ", "ウ"]

  #This isn't:
  "abc".scan(/\p{Katakana}/)
  #invalid character property name {Katakana}: /\p{Katakana}/

  #Following hack works:
  line = "abc" 
  "#{line}☃".encode('utf-8')[0..-2].scan(/\p{Katakana}/)
  #=> []

So set your String instance variables that you want to use like that:

"#{line}☃".encode('utf-8')[0..-2]

Or wrap your accessor up like that and you should be good to go without the rather unexpected behaviour of oniguruma (monster car 鬼車) throwing a wobbly just because it doesn't find a match.