From: Paul Mckibbin Date: 2008-03-20T21:30:56+09:00 Subject: Re: regexp conditional ciapecki wrote: > > The format is fixed but contains 49 fields separated by | so your one- > liner could not fit into one line :) A minor change :) input = '111|"aaaa" bbbbb|c|"22222" asdasd|ddd|"aaaa"qqqqq|jjjj' output=input.gsub(/"/,'""').gsub(/(.*?)\|(.*?)\|(.*?)/,'\1|"\2"|\3') =>111|"""aaaa"" bbbbb"|c|"""22222"" asdasd"|ddd|"""aaaa""qqqqq"|jjjj This was just to point out that there is no need for multiple replace options, but you need to know the layout is correct and in a given pattern. Robert's is the better and more robust solution (and also shorter). Mac -- Posted via http://www.ruby-forum.com/.