# 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:** 7

<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:13:10 UTC](https://meta.discourse.org/t/replace-backslash-escape-only-in-old-posts-after-import/80891/7 "2018-02-19T16:13:10Z")

</div>

This is powerful stuff 🤓 Seems like I’m slowly learning Ruby here.

I’ve thought of something like

```ruby
imported_posts = Post.where("id < 117108")
imported_posts.find_each do |post|
  raw = post.raw.gsub(/(?<=[^\\])\\%/, "\\\\%")
  post.update_column(:raw, raw)
end

```

but unfortunately, it doesn’t replace anything in `Post.raw`. Anything obvious I’m missing?

---

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