Hi I have small ruby function that splits out a Ruby array as follows:-
def rearrange arr,from,to
sidx = arr.index from
eidx = arr.index to
arr[sidx] = arr[sidx+1..eidx]
end
arr= ["Red", "Green", "Blue", "Yellow", "Cyan", "Magenta", "Orange", "Purple", "Pink", "White", "Black"]
start = "Yellow"
stop = "Orange"
rearrange arr,start,stop
puts arr.inspect
#=> ["Red", "Green", "Blue", ["Cyan", "Magenta", "Orange"], "Cyan", "Magenta", "Orange", "Purple", "Pink", "White", "Black"]
I need use use a regex expression in my start and stop searches e.g.
Start = "/Yell/"
Stop = "/Ora/"
Is there an easy way yo do this in Ruby?