I want to delete the " char from the text: This is "the Text". I want it to be: This is the Text. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Mark Toth wrote:> I want to delete the " char from the text: > > This is "the Text". > > I want it to be: > > This is the Text.This is the command where I want to use it: FasterCSV.foreach(file, :headers =>true, :col_sep =>"\t", :row_sep =>"\n") do |row| and the file includes " chars which I want to replace. Can I do something like: FasterCSV.foreach(file.gsub!(/^[\"]/,''''), :headers =>true, :col_sep =>"\t", :row_sep =>"\n") do |row| -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
lookup gsub under the String class On Dec 27, 2007 3:18 PM, Mark Toth <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > I want to delete the " char from the text: > > This is "the Text". > > I want it to be: > > This is the Text. > -- > Posted via http://www.ruby-forum.com/. > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Dec 27, 2007, at 8:18 AM, Mark Toth wrote:> > I want to delete the " char from the text: > > This is "the Text". > > I want it to be: > > This is the Text. >http://www.ruby-doc.org/core/classes/String.html and look at gsub Peace, Phillip --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Phillip Koebbe wrote:> On Dec 27, 2007, at 8:18 AM, Mark Toth wrote: > >> >> I want to delete the " char from the text: >> >> This is "the Text". >> >> I want it to be: >> >> This is the Text. >> > > http://www.ruby-doc.org/core/classes/String.html > > and look at gsub > > Peace, > PhillipI have looked into the gsub commands, but the problem is that it is not a regular char. I mean it shouldn´t be any problem if it is a % or & char, but the " char is special character in Ruby for the String. Any idea? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
You can use the single quote instead for your case. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Franz Strebel wrote:> You can use the single quote instead for your case.I don´t understand.... I have a text that containing " char and want to delete it from the text. This is "the Text". ===> This is the Text. What is the command to simple replace the " char with nothing? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Dec 27, 2007 9:47 AM, Mark Toth <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Franz Strebel wrote: > > You can use the single quote instead for your case. > > I don´t understand.... > > I have a text that containing " char and want to delete it from the > text. > > This is "the Text". > > ===> > > This is the Text. > > What is the command to simple replace the " char with nothing?newstring = string.gsub(/"/, '''') or, newstring = string.tr(''"'', '''') Both have ! (bang) versions that operate directly on the receiver rather than returning the transformed result. (but what does this have to do with Rails?) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Bob Showalter wrote:> On Dec 27, 2007 9:47 AM, Mark Toth <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > wrote: >> >> ===> >> >> This is the Text. >> >> What is the command to simple replace the " char with nothing? > > newstring = string.gsub(/"/, '''') > > or, > > newstring = string.tr(''"'', '''') > > Both have ! (bang) versions that operate directly on the receiver > rather than returning the transformed result. > > (but what does this have to do with Rails?)Thanks for your answer. Unfortunately it didn´t work when I´m using fasterCSV. This is the code so you can see what I am trying to do: file = ''c:\filename.txt'' $KCODE = "utf8" FasterCSV.foreach(file.tr(''"'', ''''), :headers =>true, :col_sep =>"\t", :row_sep =>"\n") do |row| @PriceListFileRow = row next if row.empty? a_product = Product.new( :sku => row[0] , :name => row[1] , :price => row[2] , :salestart => row[3] , :saleend => row[4] , :category => row[5] , :manufacturer => row[6] , :manufacturersku => row[7] , :othersku => row[8] , :producturl => row[9] , :stockstatus => row[10] , :shipping => row[11]) a_product.save - The problem is that fasterCSV read the file before it´s been converted with the " char. - The second problem that I have with Rails is that åäö letters doesn´t been imported correctly even when I use the $KCODE = "utf8" code. Thank you again and waiting for your answer! Best regards, Mark Attachments: http://www.ruby-forum.com/attachment/1215/filename.txt -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Why have you posted in two threads about an identical issue? This is not helping the people who are here to help. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Ryan Bigg wrote:> Why have you posted in two threads about an identical issue? This is not > helping the people who are here to help.Because the one who actually could help me in this issue still didn´t find the topic and sent me a correct answer. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---