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

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

</div>

I’m aware of `rake posts:remap["find","replace"]`.

In this specific case I guess it would be

`rake posts:remap["\\%","\\\\%"]`

However, when looking [at the code](https://github.com/discourse/discourse/blob/master/lib/tasks/posts.rake#L130-L152), it seems like regexp is also supported.

So something like

`rake posts:remap["(?<=[^\\])\\%","\\\\%","regex"]`

should replace all occurrences of `\%` which are not preceded by another `\`. But it seems this regexp is then passed along to the database layer which doesn’t support lookbehinds.

It’s tricky. Thanks for any further ideas.

---

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