gsub

hi,

im getting tired on this one. i want to replace all forwardslashes with backwardslashes.

irb: r = “C:/RAILS/” r.gsub(“/”, “\”) or r.gsub(“/”) {(''} both give me: “C:\RAILS\”

how can i use gsub to display only one ""?

regards

hi,

im getting tired on this one. i want to replace all forwardslashes with backwardslashes.

irb: r = "C:/RAILS/" r.gsub("/", "\\") or r.gsub("/") {('\'} both give me: "C:\\RAILS\\"

how can i use gsub to display only one "\"?

It's escaping it to show in the console, the string does have only one backslash.

=> "\\".size

1

:wink:

thank you…never thought about that… next question! :smiley: when i put in mit shell : i_view32.exe C:\Rails\test.png /convert=C:\Rails\test.jpg it works. but when i do system(“i_view32.exe C:\Rails\test.png /convert=C:\Rails\test.jpg”) it doesn’t work. what am i doing wrong?i guess it is escaping instead of taking it as a string. do i have to add three more "" ?

Does system(‘i_view32.exe’, ‘C:\Rails\test.png’, ‘/convert=C:\Rails\test.jpg’) work for you?

What happens when you try:   system("i_view32.exe C:\\Rails\\test.png /convert=C:\\Rails\\test.jpg") ?

“=> nil” i can start “calc.exe” from firefox via the controller that says “system(“calc.exe”)”. but i cannot start i_view32.exe or firefox.exe etc. is it a permission issue on win xp? the command is ok, i tested it in cmd.exe

Probably... I recommend a nice Linux install (even just a VM... :wink:

yep. i didnt escape the string twice…so i just got confused with the irb-way to show the string. so i used gsub(“/”, “\\”) and it worked.