From: Robert Klemme Date: 2005-10-04T17:46:47+09:00 Subject: Re: Sorry nother regexp/ruby problem Kev Jackson wrote: > Given the following data > > '817-017', 800000, 0, 0, 200000, 200000, 500000, 500000, 500000, > 500000, 60000, 59122, 0, 800000, '817' > > How can I easily just select the first 4 elements (where elements 2,3 > and 4 could be NULL)? > > At the moment I'm trying a regexp of the form > > line.sub!(/(VALUES \(\s*'\w',\s*[0-9]+,\s*[0-9]+,\s*[0-9]+|NULL).+/, > '\1 '+');') Why do you use VALUES in the regexp? I cannot see it in your sample data. It would be easier if you post sample output that you want to see. I'm not sure about the "first 4" elements (is it characters? is it items in the list?). Kind regards robert