Forum: Ruby split string's array

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.
0ec5e760f8681a0fbf7485fb3fe2fc82?d=identicon&s=25 Stevie Ray (rubyj)
on 2014-07-22 14:28
Hi, i have an array of strings like

arr = ["first part xxx / second part xxx", "first part yyy / second part
yyy"]

I have to iterate over it splitting before on each string, dividing each
string in two parts, and then "re-iterate" on each part of the new
strings splitting every word of them.

like..

arr.each do |string| string=string.split("/") end

started in th right way? ..how can I do?

thanks..
Cc704ce316e72af824ccd38cfa53104b?d=identicon&s=25 Raja Gopalan (arc)
on 2014-07-22 14:52
Hi,

arr = ["first part xxx / second part xxx", "first part yyy / second
partyyy"]

arr.each do |i|
  i.split("/").each do |j|
    puts j
  end
end
B078cb4f4fb473c7a54d1fc36d10c70e?d=identicon&s=25 Regis d'Aubarede (raubarede)
on 2014-07-22 15:13
Stevie Ray wrote in post #1153132:
> Hi, i have an array of strings like
>
> arr = ["first part xxx / second part xxx", "first part yyy / second part
> yyy"]
>



arr.join('/').split('/').each { |a| a.scan(/\w+/).each {|a| p a}}
This topic is locked and can not be replied to.