Activity Graph

Page 1 of 1


[15:30:28] warreng__: Quit: Page closed


[15:16:00] warreng__: has joined #ruby


[21:30:41] warreng__: has joined #ruby
[21:30:44] warreng__: has left #ruby: ()
[21:30:46] warreng__: has joined #ruby
[21:30:59] warreng__: quick regexp question... i have a CSV file that doesn't escape quotes. knowing that fields are comma delimited and strings are wrapped in matching double quotes, can regex convert the string "2015-07-25","Toys"r"us","-17.95" to "2015-07-25","Toys""r""us","-17.95" (notice double "" in "Toys""r""us")?
[21:32:51] warreng__: likely using lookahead and lookbehind?
[21:36:12] warreng__: tobiasvl: http://www.perlmonks.org/bare/?node_id=270993 looks about right? (perl not ruby)
[21:54:17] warreng__: tobiasvl: for what it's worth, here's the solution: File.read(path).gsub(/\r/,'').gsub(/(?<!^|,)"(?!,|$|\n)/,'""')
[21:54:46] warreng__: File.read(path).gsub(/\r/,'').gsub(/(?<!^|,)"(?!,|$)/,'""')
[21:56:16] warreng__: Quit: Page closed