Ruby Split is not working with Special Character Regex
So I have been trying to split a line when I find the Characters ^C or ^B
together. for some reason it is not splitting properly and I was hoping
someone could point me in the right direction of what I am doing wrong. I
have been on Rubular and have tested this out and supposedly it should
split it.
The lines that I am reading in and trying to split look something like this:
SOME_KEY^CSOME_VALUE^BSOME_KEY^CSOME_VALUE
final_array = []
temp_array = []
array__with_all_of_the_data.each do |x|
temp_array = x.split(/\^C/)
temp_array.each do |y|
final_array << y.split(/\^B/)
end
@final_array << final_array.join(",")
end
No comments:
Post a Comment