From: clc Date: 2006-04-25T00:29:57+09:00 Subject: Re: Scan-like Idiom to Capture a Group as a String Instead of an Array? Thanks for clarifying the operation of scan -- I mistakenly thought I was getting a string when I was actually getting an array, so my original question wasn't even correct. Anyway, all of the methods listed below seem to work, and the last one seems especially elegant. Thanks for the advice! Chris line = "name: value" value = line.scan(%r{name: ([[:alnum:]]+)}i)[0][0] puts "#{value.class}: #{value}" value = line.scan(%r{name: ([[:alnum:]]+)}i).first.first puts "#{value.class}: #{value}" value = line.match(%r{name: ([[:alnum:]]+)}i)[1] puts "#{value.class}: #{value}" value = line[%r{name: ([[:alnum:]]+)}i, 1] puts "#{value.class}: #{value}"