From: Eric Schwartz Date: 2003-06-11T01:26:44+09:00 Subject: Re: OT: Regexp question Dominik Werder writes: > With these names it works, but not for example with "New York". Then it > matches only "New"... > > Yes, I'm new to regexp... When matching what you want is hard, try matching what you don't want: 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> a.each { |state| s = state.sub(/ \(\d+\)$/, ""); p s } "Illinois" "Indiana" "Iowa" "Kansas" "Kentucky" "New York" => ["Illinois (3762)", "Indiana", "Iowa (64)", "Kansas", "Kentucky (2675)", "New York (2348)"] -=Eric -- Come to think of it, there are already a million monkeys on a million typewriters, and Usenet is NOTHING like Shakespeare. -- Blair Houghton.