I have string: "xxx | yyy | zzz | ddd" I need to split it to: "xxx", "yyy", "zzz" and "ddd", make link to every word like: <a href="xxx">xxx</a> So result must by: from this: "xxx | yyy | zzz | ddd" to this: "<a href="xxx">xxx</a>, <a href="yyy">yyy</a>, <a href="zzz">zzz</a>, <a href="ddd">ddd</a>" How can I do it? -- 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 -~----------~----~----~----~------~----~------~--~---
> I have string: "xxx | yyy | zzz | ddd" > > I need to split it to: "xxx", "yyy", "zzz" and "ddd", > make link to every word like: <a href="xxx">xxx</a> > > So result must by: > > from this: "xxx | yyy | zzz | ddd" to this: > > "<a href="xxx">xxx</a>, <a href="yyy">yyy</a>, <a href="zzz">zzz</ > a>, <a > href="ddd">ddd</a>" > > How can I do it?"xxx | yyy | zzz | ddd".split()....map{}....join() I''ll let you figure out what goes into the () and {}''s :) --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
"xxx | yyy | zzz | ddd".split(" | ") # => ["xxx", "yyy", "zzz", "ddd"] On Jan 23, 4:29 pm, Philip Hallstrom <phi...-LSG90OXdqQE@public.gmane.org> wrote:> > I have string: "xxx | yyy | zzz | ddd" > > > I need to split it to: "xxx", "yyy", "zzz" and "ddd", > > make link to every word like: <a href="xxx">xxx</a> > > > So result must by: > > > from this: "xxx | yyy | zzz | ddd" to this: > > > "<a href="xxx">xxx</a>, <a href="yyy">yyy</a>, <a href="zzz">zzz</ > > a>, <a > > href="ddd">ddd</a>" > > > How can I do it? > > "xxx | yyy | zzz | ddd".split()....map{}....join() > > I''ll let you figure out what goes into the () and {}''s :)--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---