From: Robert Klemme Date: 2003-06-11T17:49:58+09:00 Subject: Re: OT: Regexp question "Dominik Werder" schrieb im Newsbeitrag news:oprqkm3tw5jh6mnk@mail.gmx.net... > > file.gets =~ /([\w\s]+)/ > > puts $1 > thanks! also great working :) This one matches too much white space: irb(main):001:0> a = [ "Illinois (3762)", "Indiana", "Iowa (64)", "Kansas", "Kentucky (2675)", "New York (2348)" ] ["Illinois (3762)", "Indiana", "Iowa (64)", "Kansas", "Kentucky (2675)", "New York (2348)"] irb(main):002:0> irb(main):003:0* a.map do |x| irb(main):004:1* /([\w\s]+)/.match( x )[ 0 ] irb(main):005:1> end ["Illinois ", "Indiana", "Iowa ", "Kansas", "Kentucky ", "New York "] irb(main):006:0> irb(main):007:0* a.map do |x| irb(main):008:1* /\b([\w\s]+)\b/.match( x )[ 0 ] irb(main):009:1> end ["Illinois", "Indiana", "Iowa", "Kansas", "Kentucky", "New York"] irb(main):010:0> \b matches word boundaries and thus does prevent matching white space at the end of the name. Cheers robert