I want to remove all break lines recursively from string with doubles quotes but I'm only removing one.
I'm doing this but I just remove one:
string.gsub(/\"(.*)\s(.*)\"/,'\1,\2')
I want to remove all break lines recursively from string with doubles quotes but I'm only removing one.
I'm doing this but I just remove one:
string.gsub(/\"(.*)\s(.*)\"/,'\1,\2')
I would do:
string = 'hello "there cruel world"'
string.gsub(/\"[^"]+?\"/) do |match|
match.gsub(/\s+/, ', ')
end
#=> 'hello "there, cruel, world"'
Surely it is possible with a single regex, however this way is much more readable.