Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
inline double quotes
John Dax
9/2/2008 7:10:00 AM
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
--
Posted via
http://www.ruby-...
.
1 Answer
TPReal
9/2/2008 8:18:00 AM
0
John Dax 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.
--
Posted via
http://www.ruby-...
.
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
inline double quotes
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password