# Avoiding substitution "\\\\" to "\\"

**URL:** <https://www.ruby-forum.com/t/avoiding-substitution-to/262078>\
**Category:** Ruby-Forum\
**Created:** [November 11, 2021, 10:21am UTC](https://www.ruby-forum.com/t/avoiding-substitution-to/262078 "2021-11-11T10:21:41Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ped](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/838e76/32.png) [@ped](https://www.ruby-forum.com/u/ped)\
**Post date:** [November 11, 2021, 10:21am UTC](https://www.ruby-forum.com/t/avoiding-substitution-to/262078/1 "2021-11-11T10:21:41Z")

</div>

When a substitute a string with another string which includes the characters “\\”, these characters are reduced to “\”.

```
a = "Table header\n"
a << "###rows###\n"
a << "Table footer\n"

rows = "1 & 2 \\\\\\hline\n"
rows <<"3 & 4 \\\\\\hline\n"

puts rows
puts '-' * 20
puts a.gsub('###rows###', rows.chomp)

```

The result is:

```
1 & 2 \\\hline
3 & 4 \\\hline
--------------------
Table header
1 & 2 \\hline
3 & 4 \\hline
Table footer

```

Instead I would like to have:

```
Table header
1 & 2 \\\hline
3 & 4 \\\hline
Table footer

```

How can I avoid this?
