# Backslash in quotes

**URL:** <https://www.ruby-forum.com/t/backslash-in-quotes/79788>\
**Category:** Ruby\
**Created:** [March 11, 2006, 6:55am UTC](https://www.ruby-forum.com/t/backslash-in-quotes/79788 "2006-03-11T06:55:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![itsme213](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/258eb7/32.png) [@itsme213](https://www.ruby-forum.com/u/itsme213)\
**Post date:** [March 11, 2006, 6:55am UTC](https://www.ruby-forum.com/t/backslash-in-quotes/79788/1 "2006-03-11T06:55:17Z")

</div>

Why is \ the same as \ in the 1st 2 cases, but not in the 3rd?

irb(main):001:0\> ‘c:\a\b’  
=\> “c:\a\b”  
irb(main):002:0\> ‘c:\a\b’  
=\> “c:\a\b”  
irb(main):004:0\> ‘c:\a\b’  
irb(main):005:0’

Thanks.

---

<div class="post-metadata">

**Author:** ![itsme213](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/258eb7/32.png) [@itsme213](https://www.ruby-forum.com/u/itsme213)\
**Post date:** [March 11, 2006, 7:53am UTC](https://www.ruby-forum.com/t/backslash-in-quotes/79788/2 "2006-03-11T07:53:42Z")

</div>

itsme213 wrote:

> Why is \ the same as \ in the 1st 2 cases, but not in the 3rd?
> 
> irb(main):001:0\> ‘c:\a\b’  
> =\> “c:\a\b”  
> irb(main):002:0\> ‘c:\a\b’  
> =\> “c:\a\b”  
> irb(main):004:0\> ‘c:\a\b’  
> irb(main):005:0’
> 
> Thanks.

I’m new here, but I can answer this one. In the last one you are  
escaping your single ’ mark and so are not terminating the string. Do  
you mean ‘c:\a\b\’ or do you want ‘c:\a\b’’ ? To ruby it looks like  
you want to embed a \n in the string and adding another ’ and will  
complete it.  
Alan
