# Inline double quotes

**URL:** <https://www.ruby-forum.com/t/inline-double-quotes/147473>\
**Category:** Ruby\
**Created:** [September 2, 2008, 9:15am UTC](https://www.ruby-forum.com/t/inline-double-quotes/147473 "2008-09-02T09:15:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![johdax](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e47774/32.png) [@johdax](https://www.ruby-forum.com/u/johdax)\
**Post date:** [September 2, 2008, 9:15am UTC](https://www.ruby-forum.com/t/inline-double-quotes/147473/1 "2008-09-02T09:15:30Z")

</div>

hi,  
i’m searching for a way to remove inline double quotes in ruby,  
especially in a csv file.

sth like “blabla “title” blbl”;“bla bla” should become  
“blabla ‘title’ blbl”;“bla bla”

thanks in advance  
johnny

---

<div class="post-metadata">

**Author:** ![johdax](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e47774/32.png) [@johdax](https://www.ruby-forum.com/u/johdax)\
**Post date:** [September 2, 2008, 10:23am UTC](https://www.ruby-forum.com/t/inline-double-quotes/147473/2 "2008-09-02T10:23:00Z")

</div>

John D. wrote:

> hi,  
> i’m searching for a way to remove inline double quotes in ruby,  
> especially in a csv file.
> 
> sth like “blabla “title” blbl”;“bla bla” should become  
> “blabla ‘title’ blbl”;“bla bla”
> 
> thanks in advance  
> johnny

Your csv is malformed if it has such quotes, so there is no standard way  
to remove them. You’ll have to use some regular expression, for example  
if all the columns in your file are quoted, and t is a line from your  
file, try this:

t.split(/^"|";"|"$/)[1…-1].map{|e| “”#{e.gsub(/"/,"’")}""}.join(";")

Probably not the easiest method, but certainly a one-liner.

TPR.
