So I have this string
x = "{"1"=>"test","2"=>"Another=>Test","3"=>"Another=>One"}"
and I want to replace the rocket symbol that is beside a character to a pipe symbol. so the result is
x = "{"1"=>"test","2"=>"Another|Test","3"=>"Another|One"}"
I have this code right now
if x =~ /(=>\w)/).present?
x.match(/=>\w/) do |match|
#loop through matches and replace => with |
end
end
So basically my question is how do I loop through a matched by regex and replace the rocket sign to a pipe?
gsubwill let you replace parts of string by regex