How to handle string with mixed quotes in ruby.
Few examples of handling strings single and double quotes in Ruby.
%Q(This long sentence contains "double" and 'single' quotes)
=> "This long sentence contains \"double\" and 'single' quotes"
%(This long sentence contains "double" and 'single' quotes)
=> "This long sentence contains \"double\" and 'single' quotes"
Above approach works if interplolation is required.
%Q(Contains "double" and 'single' quotes with interpolation #{2 + 2})
=> "Contains \"double\" and 'single' quotes with interpolation 4"
%(Contains "double" and 'single' quotes with interpolation #{2 + 2})
=> "Contains \"double\" and 'single' quotes with interpolation 4"
Thanks for reading!