Forum: Ruby on Rails String split help

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Ead43bcb0202410540a6a7cee5955d46?d=identicon&s=25 Fresh Mix (giga)
on 2009-01-23 23:27
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?
2505b282d57c29be797dc35b245adb4c?d=identicon&s=25 Philip Hallstrom (Guest)
on 2009-01-23 23:30
(Received via mailing list)
> 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 :)
6fabb84e727dee98d1277df56458cbac?d=identicon&s=25 Andrew Bloom (Guest)
on 2009-01-24 17:15
(Received via mailing list)
"xxx | yyy | zzz | ddd".split(" | ") # => ["xxx", "yyy", "zzz", "ddd"]
This topic is locked and can not be replied to.