ok, been going on this for an hour now, and can not find a solution I want to find all content between <code> tags in a string and replace the content of these with new formatted content. Any suggestions why the following code is not working? self.content = self.content.gsub(/<code>(.*?)<\/code>/, ''new content'') Cheers Josh -- 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 Apr 26, 2007, at 20:04 , josh wrote:> I want to find all content between <code> tags in a string and replace > the content of these with new formatted content. Any suggestions > why the > following code is not working? > > self.content = self.content.gsub(/<code>(.*?)<\/code>/, ''new content'')Nope, because it is working: irb(main):026:0> "This is <code>stuff</code>".gsub(/<code>(.*?)<\/ code>/, ''new content'') => "This is new content" You need to provide more details and code if you''re experiencing something different. -- Jakob Skjerning - http://mentalized.net --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hi, Last comment got me thinking and after testing of the code, and have found that it breaks if there is a new line ''\n'' within the <code>. Does anyone know how to get the (.*?) to accept new lines ( \n ) thanks josh Jakob Skjerning wrote:> On Apr 26, 2007, at 20:04 , josh wrote: > >> I want to find all content between <code> tags in a string and replace >> the content of these with new formatted content. Any suggestions >> why the >> following code is not working? >> >> self.content = self.content.gsub(/<code>(.*?)<\/code>/, ''new content'') > > Nope, because it is working: > > irb(main):026:0> "This is <code>stuff</code>".gsub(/<code>(.*?)<\/ > code>/, ''new content'') > => "This is new content" > > You need to provide more details and code if you''re experiencing > something different. > > -- > Jakob Skjerning - http://mentalized.net-- 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 -~----------~----~----~----~------~----~------~--~---
Hi,> found that it breaks if there is a new line ''\n'' within the <code>. Does anyone know how to get the (.*?) to accept new lines ( \n ) >you can set a multiline regexp pattern by adding m after the pattern, like in /.*/m regards, javier ramirez -- -------- Estamos de estreno... si necesitas llevar el control de tus gastos visita http://www.gastosgem.com !!Es gratis!! --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Thanks :-) javier ramirez wrote:> Hi, >> found that it breaks if there is a new line ''\n'' within the <code>. Does anyone know how to get the (.*?) to accept new lines ( \n ) >> > you can set a multiline regexp pattern by adding m after the pattern, > like in /.*/m > > regards, > > javier ramirez > > -- > -------- > Estamos de estreno... si necesitas llevar el control de tus gastos > visita http://www.gastosgem.com !!Es gratis!!-- 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 -~----------~----~----~----~------~----~------~--~---