From: Kvetch Kvetch Date: 2009-12-14T05:34:17+09:00 Subject: gsub help I am reading in a file that is basically a csv file but the delimiter is spaces. I am also using fastercsv to parse the file into an array. Before fastercsv reads it I am substituting all spaces into commas with gsub l.gsub!(" ", ",") I have one column in each row that could contain spaces. For example firstname,lastname,phonenumber,streetname,zip john crichton 555-555-1234 ^A street name with spaces^ 12345 turns into john,crichton,555-555-1234,A,street,name,with,spaces,12345 I can place the column that could contain spaces at the end of each row and then call like this but I would like to preserve those spaces. FasterCSV.parse(l) do |row| name=row[1] lastname=row[2] phone=row[3] zip=row[4] street=row[6...10] Each street name starts with a ^ and ends with a ^. Does anyone know if there is way I can replace all spaces up until the first ^ and then begin again after the last ^ so the street name is preserved with spaces and each column is separated by commas so my result set looks like the following? john,crichton,555-555-1234,A street name with spaces,12345 Thanks -- Posted via http://www.ruby-forum.com/.