From: Rodrigo Bermejo Date: 2008-06-05T09:14:40+09:00 Subject: Re: Removing Special Chars from a String Jeff Miller wrote: > Hello, > I'm pulling some fields out of an Oracle database and creating a CSV. > However, some fields have \n and \r in them, which messes up my CSV. Is > there a special function or a certain way I should try to get rid of > them? I tried using chomp, chomp!, strip, and strip! but I can't seem to > get it formatted the right way. An example string would be: > > "\nhere is some text\r\n\r\nsome more text\n\r\n\reven more text" > > Any suggestions? > > Thanks, > - Jeff If you want to delete them use this: "\nhere is some text\r\n\r\nsome more text\n\r\n\reven more text".gsub(/\r|\n/,"") You can use: require 'csv' , it allows you to create/modify CSV with \r & \n without messing up the data. -r. -- Posted via http://www.ruby-forum.com/.