String = "Test string Test"
array = ["link1","link2"]
How can replace string like this ?
Output should be String = "link1 string link2"
String#gsub! could return an enumerator, so this is easy:
string.gsub!("Test").each_with_index { |v, i| array[i] }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With