Forum: Ruby split string's array

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..
5dfc843f9ecf6fb64b52a35bdce43910?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}}
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.