# String split help

**URL:** <https://www.ruby-forum.com/t/string-split-help/158498>\
**Category:** Rails\
**Created:** [January 23, 2009, 11:27pm UTC](https://www.ruby-forum.com/t/string-split-help/158498 "2009-01-23T23:27:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![giga](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/b9bd4f/32.png) [@giga](https://www.ruby-forum.com/u/giga)\
**Post date:** [January 23, 2009, 11:27pm UTC](https://www.ruby-forum.com/t/string-split-help/158498/1 "2009-01-23T23:27:39Z")

</div>

I have string: “xxx | yyy | zzz | ddd”

I need to split it to: “xxx”, “yyy”, “zzz” and “ddd”,  
make link to every word like: xxx

So result must by:

from this: “xxx | yyy | zzz | ddd” to this:

“xxx, yyy, zzz, ddd”

How can I do it?

---

<div class="post-metadata">

**Author:** ![giga](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/b9bd4f/32.png) [@giga](https://www.ruby-forum.com/u/giga)\
**Post date:** [January 23, 2009, 11:30pm UTC](https://www.ruby-forum.com/t/string-split-help/158498/2 "2009-01-23T23:30:38Z")

</div>

> a\>, ddd"
> 
> How can I do it?

“xxx | yyy | zzz | ddd”.split()…map{}…join()

I’ll let you figure out what goes into the () and {}'s 🙂

---

<div class="post-metadata">

**Author:** ![giga](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/b9bd4f/32.png) [@giga](https://www.ruby-forum.com/u/giga)\
**Post date:** [January 24, 2009, 5:15pm UTC](https://www.ruby-forum.com/t/string-split-help/158498/3 "2009-01-24T17:15:31Z")

</div>

“xxx | yyy | zzz | ddd”.split(" | ") # =\> [“xxx”, “yyy”, “zzz”, “ddd”]
