String to String?

Really basic question.

How can I convert “this” to ‘this’

convert from a double quotes string to a single quotes string.

On Tue, Jan 12, 2010 at 11:11 PM, [email protected]
[email protected]wrote:

Really basic question.

How can I convert “this” to ‘this’

convert from a double quotes string to a single quotes string.

For what purpose?

-Conrad

u can try this

@re = “this”.gsub(“this”,"‘this’")
puts @re
Thanks
seenu

I could be misreading, but I thought it was a simple question of how to
change double quotes to single quotes.

try
var = ‘“this”’
var.gsub!(’"’,"’")

Cheers
Simon

On Wed, 13 Jan 2010 16:14:47 +0800, srinivasan sakthivel

[email protected] wrote:

Really basic question.

How can I convert “this” to ‘this’

convert from a double quotes string to a single quotes string.

Try this one :-
str = ‘“hai”’
puts str
puts str.sub(/^"(.*)"$/, ‘’\1’’)

Thanks guys, was having some issues creating headings based on an
array of column names from the DB acquired using User.column_name
where “User” is the table. Turns out my problem was unrelated in the
link_to code…should have went to bed sooner.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs