# How to replace from "\\" to "/"

**URL:** <https://www.ruby-forum.com/t/how-to-replace-from-to/117057>\
**Category:** Rails\
**Created:** [October 12, 2007, 2:29pm UTC](https://www.ruby-forum.com/t/how-to-replace-from-to/117057 "2007-10-12T14:29:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![vidyagayathri](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/ba9def/32.png) [@vidyagayathri](https://www.ruby-forum.com/u/vidyagayathri)\
**Post date:** [October 12, 2007, 2:29pm UTC](https://www.ruby-forum.com/t/how-to-replace-from-to/117057/1 "2007-10-12T14:29:49Z")

</div>

HI all,

i want to replace slashes like this, please help me to do this,  
thanks in advance.

From = .\script…\config…\gentran\test4.txt

To = ./script/…/config/…/gentran/test4.txt

---

<div class="post-metadata">

**Author:** ![vidyagayathri](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/ba9def/32.png) [@vidyagayathri](https://www.ruby-forum.com/u/vidyagayathri)\
**Post date:** [October 12, 2007, 2:32pm UTC](https://www.ruby-forum.com/t/how-to-replace-from-to/117057/2 "2007-10-12T14:32:54Z")

</div>

There’s always File.join, which puts in the appropriate slashes where  
necessary. Otherwise, gsub:

path\_string.gsub(/\/, “/”)

Jason

---

<div class="post-metadata">

**Author:** ![vidyagayathri](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/ba9def/32.png) [@vidyagayathri](https://www.ruby-forum.com/u/vidyagayathri)\
**Post date:** [October 12, 2007, 2:36pm UTC](https://www.ruby-forum.com/t/how-to-replace-from-to/117057/3 "2007-10-12T14:36:37Z")

</div>

Hi jason,

Thanks for your quick reply, i got the answer with ur help
