From: Joel Pearson Date: 2013-04-19T03:37:05+09:00 Subject: Re: Match against multiple patterns problem How about this? def test(s) return ['1',''] if !s.is_a?(String) || s.empty? case s when /^([^\W_]+)/ ['a', $1] when /^(\s+)/ ['s', $1] when /^([[:cntrl:]]+)/ ['c', $1] when /^([[:punct:]_]+)/ ['p', $1] when /^([^\w\s[:cntrl:][:punct:]]+)/ ['r', $1] end end -- Posted via http://www.ruby-forum.com/.