From: Xavier Noria Date: 2008-03-19T18:09:29+09:00 Subject: Re: regexp conditional On Mar 19, 2008, at 10:00 , ciapecki wrote: > Hi, > > How could I easily do the following?: > > input = '111|"aaaa" bbbbb|c' > > I would like to get as output following: > > output = '111|"""aaa"" bbbbb"|c' > > to correct wrongly prepared pipe separated file with enclosing the > equation characters. My interpretation of what you need is: input = '111|"aaaa" bbbbb|c' fields = input.split('|') fields[1].gsub!('"', '""') fields[1] = %Q{"#{fields[1]}"} output = fields.join('|') Depending on the input that may not be valid, for example if fields[1] may contain a pipe. Anyway being a mal-formed input assumptions depend on the actual data. -- fxn