# Replace backslash escape only in old posts after import

**URL:** <https://meta.discourse.org/t/replace-backslash-escape-only-in-old-posts-after-import/80891>\
**Category:** Product Support\
**Created:** [18.Февраль.2018 17:20:08 UTC](https://meta.discourse.org/t/replace-backslash-escape-only-in-old-posts-after-import/80891 "2018-02-18T17:20:08Z")\
**Posts on this page:** 1\
**Showing post:** 9

<div class="post-metadata">

**Author:** ![fhe](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fhe/32/113345_2.png) [@fhe](https://meta.discourse.org/u/fhe)\
**Post date:** [19.Февраль.2018 16:59:44 UTC](https://meta.discourse.org/t/replace-backslash-escape-only-in-old-posts-after-import/80891/9 "2018-02-19T16:59:44Z")

</div>

No, but apparently I was missing some additional escapes. This is what works now:

```plaintext
raw = post.raw.gsub(/(?<=[^\\])\\\%/, '\\\\\%')

```

Using `'\\\\\%'`over `"\\\\\%"`also makes a difference.

Thanks for initially pointing me to the Rails console, @pfaffman!

---

_[View the full topic](https://meta.discourse.org/t/replace-backslash-escape-only-in-old-posts-after-import/80891)._
