Fix regexp problem in ruby 1.8.7
Fix #type method definition in ruby 1.8.7