From: Charles Hixson Date: 2013-04-19T02:40:54+09:00 Subject: Match against multiple patterns problem What I would want to do, if it were legal code would be: if not s.is_a?(String) or len(s) < 1 then return ["1",""] if (m = /^[^\W_]+/.match(s) ) !== nil then return ["a", m[0]] elsif (m = /^\s+/.match(s) ) != nil then return ["s", m[0]] elsif (m = /^[[:cntrl:]]+/) != nil then return ["c", m[0]] elsif (m = /^[[:punct:]_]+/) != nil then return ["p", m[0]] elsif (m = /^[^\w\s[:cntrl:][:punct:]]+/) != nil then return ["r", m[0]] But this isn't legal, because one can't do an assignment within a logic test (any expression?). So what SHOULD I do? I can double the length of the code by pulling the assignments out, and interleaving tests and assignments, but that's ugly (i.e., it makes the code harder to read). Any better choices? -- Charles Hixson