I have a hash like:
{:name => 'foo', :country => 'bar', :age => 22}
I also have a string like
Hello ##name##, you are from ##country## and your age is ##age##. I like ##country##
Using above hash, I want to parse this string and substitute the tags with corresponding values. So after parsing, the string will look like:
Hello foo, you are from bar and your age is 22. I like bar
Do you recommend taking help of regex to parse it? In that case if I have 5 values in the hash, then I would have to traverse through string 5 times and each time parsing one tag. I don't think that is a good solution. Is there any better solution?