# HTML-tags opschonen in alle posts na migratie?

**URL:** <https://meta.discourse.org/t/clean-up-html-tags-in-all-posts-after-migration/172094>\
**Category:** Migration\
**Tags:** flarum\
**Created:** [3 december 2020 om 10:28 UTC](https://meta.discourse.org/t/clean-up-html-tags-in-all-posts-after-migration/172094 "2020-12-03T10:28:58Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)\
**Post date:** [21 december 2020 om 18:47 UTC](https://meta.discourse.org/t/clean-up-html-tags-in-all-posts-after-migration/172094/7 "2020-12-21T18:47:08Z")

</div>

Here’s code that does something similar:

```ruby
posts=Post.where("raw like '%Sent from%using Tapatalk'")

posts.each do |post|
   post.raw.gsub!(/^Sent from my.+?using Tapatalk$/,"")
   post.save
   post.rebake!
end

```

I don’t think that you need to do something “smart” for images or URLs unless they are somehow broken.

You want something like

```
   post.raw.gsub!(/\/?\[p\]/ig,"\n")

```

to replace `[p]` and `[/p]` with a newline (an extra newline won’t hurt, but you can remove the `\n` if you don’t think you need a newline), but I haven’t tested, so this is probably wrong. You can test in something like [https://rubular.com/](https://rubular.com/).

---

_[View the full topic](https://meta.discourse.org/t/clean-up-html-tags-in-all-posts-after-migration/172094)._
